Go

Go Hello World

2019-03-01  本文已影响0人  JaedenKil

Jetbrains go IDE: GoLand.

package main

import "fmt"

func main() {
    fmt.Println("Hello World")
}

Prints:

Hello World

Be aware, the package name has to be main, explained here:

A complete program is created by linking a single, unimported package called the main package with all the packages it imports, transitively. The main package must have package name main and declare a function main that takes no arguments and returns no value.
func main() { … }

Program execution begins by initializing the main package and then invoking the function main. When that function invocation returns, the program exits. It does not wait for other (non-main) goroutines to complete.

上一篇 下一篇

猜你喜欢

热点阅读