godo
godo copied to clipboard
Gododir handling
I thought Gododir would become a package providing func Tasks(p *Project)
as the main entry point; dropping the need for a Godofile.go and allowing the user to split functionality/tasks across go multiple files. Maybe this is also what you want to do in the end, but v1.2 is still relying on a single file named Gododir/Godofile.go
.
I propose to change godo's behaviour concerning Gododir
in the following (backwards compatible) way:
The godo
cmd will use the standard library go/build
package to parse the go files in Gododir
. If the package is a main
package, it is expected that it contains a main()
function and is built+executed directly. If the package name is different, a Godofile_main.go
is written to tmp and executed with go run
(same behaviour as current situation).
If there is a Gododir
AND a tasks/Godofile.go
, the first one is used.
For non-main packages the func Tasks(p *Project)
is defined as godo entry point.
For consistency we could enforce the usage of package tasks
instead of package <anything>
. This is a breaking change of course, but very easy to update.
I would be happy to implement this.
I'm not understanding func Tasks(p *Project
as the main entry point. Show a gist of the files of an example having a hello world task and another task that depends on it. I'll understand better. What's important is that there isn't too much magic breaking editor code completion.
Right now when a Godofile is not a package main you generate a Godofile_main.go file that imports the Godofile.go as a package and runs godo.Godo(pkg.Tasks). https://github.com/go-godo/godo/blob/master/cmd/godo/main.go#L91:L98
I propose that this behaviour stays the same. But instead it checks the complete Gododir
directory to be a main or non-main package by using go/build
instead of checking just the single Gododir/Godofile.go
file with regexp.
I've created a gist explaining some of the ideas, please start with reading the README https://gist.github.com/GeertJohan/ffb378b6e6522e2b4661
Any thoughts on this? If you agree I can do implementation
on holidays. sure!