To compile and run a simple program, first choose a module path (we'll use
example/user/hello
) and create a go.mod
file that
declares it:
$ mkdir hello # Alternatively, clone it if it already exists in version control.
$ cd hello
$ go mod init example/user/hello
go: creating new go.mod: module example/user/hello
$ cat go.mod
module example/user/hello go 1.16
$
If you want to change selection, open document below and click on "Move attachment"
How to Write Go Code - The Go Programming Languageo-cmp contains a package in the directory cmp/. That package's import path is github.com/google/go-cmp/cmp. Packages in the standard library do not have a module path prefix. Your first program <span>To compile and run a simple program, first choose a module path (we'll use example/user/hello) and create a go.mod file that declares it: $ mkdir hello # Alternatively, clone it if it already exists in version control. $ cd hello $ go mod init example/user/hello go: creating new go.mod: module example/user/hello $ cat go.mod module example/user/hello go 1.16 $ The first statement in a Go source file must be package name. Executable commands must always use package main. Next, create a file named hello.go inside that directory containing the f Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details