美文网首页Go
Go Hello World

Go Hello World

作者: JaedenKil | 来源:发表于2019-03-01 15:03 被阅读0次

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.

相关文章

网友评论

    本文标题:Go Hello World

    本文链接:https://www.haomeiwen.com/subject/fopduqtx.html