Projects & Modules
Task | Code Example | Description |
---|---|---|
Creating a new go project | mkdir myproject | |
Download modules | go mod vendor | https://go.dev/ref/mod#go-mod-vendor |
Cleanup modules | go mod tidy | Ensures that the |
Building
Task | Code Example | Description |
---|---|---|
Build | go build -o mysvc | Build project |
Types/Objects
Task | Code Example | Reference |
---|---|---|
Creating an instance of a struct |
| link |
Creating an instance of a struct |
| |
Implementing an Interface | package main import "fmt" type I interface { M() } type T struct { S string } // This method means type T implements the interface I, // but we don't need to explicitly declare that it does so. func (t T) M() { fmt.Println(t.S) } func main() { var i I = T{"hello"} i.M() } | link |
References
Reference | URL |
---|---|
Go Home | https://go.dev |
Go Documentation | https://go.dev/doc/ |
Tutorials | https://go.dev/doc/tutorial/ |
Go by Example | https://gobyexample.com |