I was playing and learning with the beego framework for go, but my hello world example didn't run and from what I determine is that beego does a chdir based on os.Args[0] and that the program is run there. And that is why the app runs, but can't find the views directory.
So backtracking to a simpler level, filename 'example.go':
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println(os.Getwd())
fmt.Println(os.Args[0])
}
Will output:
/<directory 'go run this_file.go' was run in>/ <nil>
/tmp/go-build178877254/command-line-arguments/_obj/exe/example
I don't understand enough about go as why this the way it is. My first thought is that I'm using gvm (go version manager) and this is happening because something is off. Any help appreciated.
EDIT:
Apparently,
go build
./example
produces a better, expected, and successful outcome:
<directory './example' was run in>/ <nil>
<directory './example' was run in>/