When I run go run main.go from cmd folder I’m getting html/template: pattern matches no files: "templates/*" error. And when I run go test from home page, all tests are passing. To make go run main.go working I have to change pattern to ("../templates/*") but in that case go test will fail.
I guess that is something with building process that I still don’t understand. Can someone explain it to me?
Thanks
When you are inside home/cmd, that is your current directory. Looking for templates/* at that point means looking for home/cmd/templates/* which is incorrect.
Generally, don’t use go run. Use go install to create a binary. Run it, from the place you want to be your current directory.
Perhaps even more generally, realize that the templates you mention are not compiled in, they are loaded at runtime. (Maybe you were totally aware of this, just mentioning for completeness.)