How to run Go first program in fedora ?

How to run Go program in fedora ?

Create file 'first-go.go' with below Go code using any text editor.

Simple basic Go programming to display string 'first go program, welcome'.

//First Go program

package main                                                               	 
                                                                           	 
import "fmt"                                                               	 
                                                                           	 
func main() {                                                              	 
    	fmt.Printf("first go program, welcome\n")                                       	 
} 	 

Build an executable first-go in the directory alongside your source code. here golang executable file will be created.

$ go build

If more than one Go programming code files are there, we can use file name to build it. first-go executable file will be created if we use go program file name 'first-go.go'.

$ go build first-go.go

Execute Go program

./first-go

Output:

]$ ./first-go
first go program, welcome!