[Related article] How to build the Go language environment in Linux

With the Go environment set up, let’s build and run our first Go program.

Create a project directory:

$GOPATH/ SRC /test $GOPATH/ SRC /testCopy the code

2, create a test file, write test program code, save exit:

Package main import "FMT" func main() {FMT.Printf("PHP is the best language in the world! \n")} # Save and exit :wqCopy the code

3. Construction Project:

go build
Copy the code

After the build, a compiled file will appear in the project directory, as shown in the test file:

4. Directly enter the file name of the compiled file on the command line and press Enter. The result is returned as shown in the figure below: