illud
(Illud)
November 10, 2020, 2:05am
1
Is it ok to import the same folder several times? I do it like this becouse the files of my routes are in that folder and I add the identifier to know what route it is and then call the function.
inside my routes folder i have
routes_
|_ route_1.go
|_ route_2.go
|_ route_3.go
Import example
import(
Route1 "./routes"
Route2 "./routes"
Route3 "./routes"
)
func main(){
Route1.get()
Route2.post()
Route3.put()
}
NobbZ
(Norbert Melzer)
November 10, 2020, 5:47am
2
All files in the same folder belong to the same package, so all 3 imports are the same anyway, therefore it is not necessary to to do 3 imports.
1 Like
What about importing from a different folder?
I’m using wasm, and in Svelte want to access the same Go package from components that may be in different subfolders of the root where the Go/wasm is imported.
I’m not even sure this is a Go question!
1 Like
NobbZ
(Norbert Melzer)
November 10, 2020, 10:42am
4
The “same” go package can not be in different folders.
All files in a folder belong to the same package, different folders are different packages.
1 Like
amnon
(amnon bc)
November 19, 2020, 9:07pm
5
Imports should really have a full path
eg “github.com/gorilla/mux ”
Relative paths should not be used as they don’t work very well.
system
(system)
Closed
February 17, 2021, 9:14pm
6
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.