I’m new to Go. I’ve browsed around on this issue but can’t find anything with a solution that applies to my case. Code available at GitHub - neut0ne/todo: Simple task manager to learn Go..
I try to run a program. It has 2 files in use, main.go and cmd/root.go.
This is main.go:
package main
import "github.com/neut0ne/todo/cmd"
func main (){
cmd.RootCmd.Execute()
}
This is cmd/root.go:
package cmd
// This is the root command.
import "github.com/spf13/cobra"
var RootCmd = &cobra.Command{
Use: "Todo",
Short: "Todo is a small and efficient task manager.",
// Long: `A Fast and intuitive basic task mamagement tool built with
// love by neut0ne and friends in Go.
// Complete documentation is available at http://todo.neut0ne.go`,
// Run: func(cmd *cobra.Command, args []string) {
// // Do Stuff Here
// },
}
I’m told you’re supposed to be able to go mod init ~/todo
to create a module for the program,
and then be able to just type todo
to run the program.
todo
gives nothing.
Standing in ~/todo locally and typing go run main.go
gives the error message below:
main.go:3:8: import “github.com/neut0ne/todo/cmd” is a program, not an importable package
I have run go install root.go
and go install cmd
.
GOPATH: ~/code/go/src/github.com/neut0ne/todo
go version go1.14.2 darwin/amd64
What am I doing wrong?