I\'ve used GOPATH but for this current issue I\'m facing it does not help. I want to be able to create packages that are specific to a project:
Perhaps you're trying to modularize your package. I'm assuming that package1 and package2 are, in a way, part of the same package but for readability you're splitting those into multiple files.
If the previous case was yours, you could use the same package name into those multiples files and it will be like if there were the same file.
This is an example:
add.go
package math
func add(n1, n2 int) int {
return n1 + n2
}
subtract.go
package math
func subtract(n1, n2 int) int {
return n1 - n2
}
donothing.go
package math
func donothing(n1, n2 int) int {
s := add(n1, n2)
s = subtract(n1, n2)
return s
}
I am not a Go expert and this is my first post in StackOveflow, so if you have some advice it will be well received.