I am new to go module building. What im trying to do is to create a go library with commonly used methods that other developers can use in their go code.
So first in my internal github, Ive created a repo https://internalgithub/<org>/lib-go.git
The repo structure looks like
$ tree
.
├── README.md
├── go.mod
├── go.sum
└── main.go
And the main.go
file has the following content
package main
import (
"flag"
"os"
"path/filepath"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)
func main() {}
func someFunctinDevelopersNeed(cluster bool) kubernetes.Interface {
if cluster == false {
var kubeconfig *string
.
.
return clientset
}
The code is available in the master branch of my org github.
The next task to to write code that invokes this library and in turn invokes the methid someFunctinDevelopersNeed
So in my app code, my main.go looks like
package main
import "internalgithub/<org>/lib-go"
func main() {
clientset = someFunctinDevelopersNeed()
.
.
}
But when I try to do go get -t -v internalgithub/<org>/lib-go
, I get
runtime.main_main·f: function main is undeclared in the main package
Is there something I have missed ?
EDIT:
Based on suggestions, now I have done the following
$ tree
.
├── README.md
├── go.mod
├── go.sum
└── kubernetes
└── kubernetes.go
And kubernetes.go
starts with
package kubernetes
import (
"flag"
"os"
"path/filepath"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)
func someFunctinDevelopersNeed(cluster bool) kubernetes.Interface {
if cluster == false {
var kubeconfig *string
.
.
return clientset
}
Even with these changes, I run into the same error