Short and sweet tutorial on importing local packages
Create a folder, now inside of it run
go mod init mempool
next
mkdir -p maths/rands
now
touch maths/abs.go maths/rands/fermat.go run.go
you should have this
Populate your abs.go
with this
package mathsimport ( "fmt")func HelloWorld() { fmt.Println("Hello World");}
Smack this into your fermat.go
package randsimport "mempool/maths"func Main() { maths.HelloWorld();}
finally, your run.go
looks like this
package mainimport "mempool/maths/rands"func main() { rands.Main();}
now, run go run .
in the root directory. Well done!
This tutorial was written with go version go1.16.2 linux/amd64