Go/Quick Start: Difference between revisions
< Go
Jump to navigation
Jump to search
| Line 31: | Line 31: | ||
mkdir greetings | mkdir greetings | ||
go mod init sandbox/greetings | go mod init sandbox/greetings | ||
go mod edit -replace sandbox/greetings=./greetings | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 36: | Line 37: | ||
mkdir sucks | mkdir sucks | ||
go mod init sandbox/sucks | go mod init sandbox/sucks | ||
go mod edit -replace sandbox/sucks=./sucks | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 02:43, 22 May 2025
Create a module
Create module and source file.
go mod init sandbox/hello
touch hello.go
Add source code.
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Run.
go run .
Work with 2 modules
mkdir greetings
go mod init sandbox/greetings
go mod edit -replace sandbox/greetings=./greetings
mkdir sucks
go mod init sandbox/sucks
go mod edit -replace sandbox/sucks=./sucks