Hello World Program in Golang
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}
A Go program always follows this general structure.
- The package declaration,
package main
in this case. - Import statements, if any. In this example, we import the
fmt
package. - The rest. In this example, it comprises the the main function, which includes one statement,
fmt.Println("Hello World!")
.
If you compile and run this program, you will get the following output:
Hello World!
What's Next
If you are interested in learning programming in Go, then go ahead and set up a development environment.
- Next Step: Go development environment setup
C C++ C# Clojure Crystal D Dart Erlang F# Haskell Java Javascript Julia Kotlin Lua Python Rust Scala Swift Typescript