-
-
Save 6rube/65d105c5ba8192e26fffd190d82526f2 to your computer and use it in GitHub Desktop.
Go Modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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