I wonder if there is a way to use namespaces in Go just like Python does.
In Python, if I have the following files containing functions:
/a.py def foo(): /b.py def bar():
I can access fooand barin the third Python file as follows:
foo
bar
import a a1 = a.foo() import b b1 = b.bar()
I'm having difficulty finding some documentation on Go namespaces. How are namespaces implemented? With packageand import? Or importintended for external libraries?
package
import
, , . , , , . , ( ).
Go Python - . Python, , Go . , .
, Python, $GOPATH/src/a/a.go :
$GOPATH/src/a/a.go
package a import "fmt" func Foo() { fmt.Println("a.Foo") }
:
package main import "a" func main() { a.Foo() }
, a . , ( foo foo).
a
Go, . , import "./a", a a/a.go .
import "./a"
a/a.go
Source: https://habr.com/ru/post/1535957/More articles:how does it work asynchronously under the hood ..? - javascriptLevenshtein Distance and Modern Indices in Neo4j - searchHow to set default value for ASP.NET MVC DropDownList from model - asp.net-mvcboost thread and try_join_for each time give different results - c ++JQuery UI calendar - how to highlight days after current date? - javascriptHow to remove Blend for Visual Studio 2012? - visual-studio-2012OpenGL ES 2.0 - Textures are always black - androidDoing math with LESS variables for animated keyframes - cssUsing redis with logstash - redisA universal subset of regular expressions? Or a comprehensive grammar table of attributes - regexAll Articles