I want to use a functions in my libGo.go
. All topics that I watched for solve my problem is to push my folder on GitHub and in my go.mod
use line require github.com/pseudo/project
. Last Information I don't put my project on my GOPATH
.
Architecture:
.
├── go.mod
├── libGo
│ └── libGo.go
└── main.go
libGo.go
package libGo
import "fmt";
func Hello() {
fmt.Println("Hello");
}
func Calcule(x, y int) int {
return (x + y);
}
main.go
package main;
import (
"fmt"
"example.com/libGo/libGo"
);
func main() {
fmt.Println("I'm main function");
libGo.Hello()
}
go.mod
module example.com/libGo/libGo
go 1.15
error message:
package command-line-arguments
imports example.com/libGo/libGo
imports example.com/libGo/libGo: import cycle not allowed
I am a beginner at Golang, so if you can explain to me with an example and a description of why what I have done doesn't work I would be grateful.
Topics Read(first answer with 46 votes): Accessing local packages within a go module (go 1.11)