Just 3 days experience in Go language. Hope an example will be more apt to understand my confusion.
root@freebsd1:/usr/home/arun/go-start/src/test2 # go mod init f1/f2/f3/f4/f5/hello
go: creating new go.mod: module f1/f2/f3/f4/f5/hello
root@freebsd1:/usr/home/arun/go-start/src/test2 #
Here in above example go mod init
is creating all these folders(f1/f2/f3/f4/f5/hello
)?. I searched a lot, couldn't find any such folders in system. Then what is the significance of this path.
Even though below command will not run if this path is not mentioned as it is
# go install f1/f2/f3/f4/f5/hello
--:EDIT:--
May be this will help someone later ( Just walk through the steps to understand this in a proper way, especially for newbies )
I am planning to create a program 'calculator' and will upload in GitHub later.
I will keep the functions in different packages like
sum
,multiply
etcfirst step
#go mod init github.com/go-arun/calculator
( Don't confuse here , this is just an assumption that, in future I may create a repository in github for this project )created folder
sum
(one of the package folder , and createdsum.go
inside )
See those in by system:
1.
root@debian1:/home/arun/lab# go mod init github.com/go-arun/calculator
go: creating new go.mod: module github.com/go-arun/calculator
root@debian1:/home/arun/lab# cat go.mod
module github.com/go-arun/calculator
go 1.15
2.
root@debian1:/home/arun/lab# cat sum/sum.go
package sum
import "fmt"
func Sum(num1,num2 int)(){
fmt.Println(num1+num2)
}
3.
root@debian1:/home/arun/lab# cat main.go
package main
import(
"github.com/go-arun/calculator/sum"
)
func main(){
n1 := 10
n2 := 10
sum.Sum(n1,n2)
}
4.
root@debian1:/home/arun/lab# tree
.
|-- go.mod
|-- main.go
`-- sum
`-- sum.go