I'm pretty new on Go but I'm from the C++ school. I just want to make a project and split the logic into multiple files.
In C++ I just need to put on my main_file.cpp
a single
#include "my_own_lib.hpp"
(similar to module.exports
and then require('relative/path/to/my-own-lib')
in Node.js)
and that's it. In Go I followed the same logic but my result is:
$ go run main.go
main.go:4:8: open /Users/mt/Documents/Codes/go/src/github.com/mt/Apollo/tst: no such file or directory
My files:
main.go
package main
import "fmt"
import "./tst"
func main() {
fmt.Println("just testing")
tst.p()
}
tst.go
package tst
import "fmt"
func p() {
fmt.Println("ola")
}
Of course my file structure is:
myFolder/
|- main.go
|_ tst.go
Could someone tell me what is the right way to do this?