Go/Quick Start

From Fundamental Ramen
Jump to navigation Jump to search

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