Skip to content

Instantly share code, notes, and snippets.

@6rube
Last active February 3, 2022 10:34
Show Gist options
  • Save 6rube/65d105c5ba8192e26fffd190d82526f2 to your computer and use it in GitHub Desktop.
Save 6rube/65d105c5ba8192e26fffd190d82526f2 to your computer and use it in GitHub Desktop.
Go Modules
Hell
├── main.go
└── world
└── test.go
------------------------------------------|------------------------------------------
main.go: |test.go:
package main | package world
import "example.com/modulename/world" | import "fmt"
func main(){world.Quest()} | func Quest(){fmt.Println("test done!")}
------------------------------------------|------------------------------------------
1. run "go mod init example.com/modulename
2. Import with main.go -> import "example.com/modulename/world"
3. Call the function "Quest" with main.go -> "world.Quest()"
[IMPORTANT: Your function has to start with a capilat letter because god knows why] <- https://golang.org/ref/spec#Exported_identifiers
5. Profit
Reference: https://blog.golang.org/using-go-modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment