05+Packages+&&+Docs+(code+organization)+Golang
05+Packages+&&+Docs+(code+organization)+Golang
unique namespaces
You can think of “packages” as just another name for “folders.”
The unique name of a “package” is the path after the “src” folder
- this will make more sense in a moment
PACKAGES = FOLDERS
Godoc.org documents
the go language.
Examples include:
● file systems are namespaces that assign names to files
● programming languages organize variables and subroutines in namespaces
● computer networks and distributed systems assign names to resources, such as computers, printers,
websites, (remote) files, etc.
Namespaces are commonly structured as hierarchies to allow reuse of names in different contexts.
Example: human names. Jane Doe. Within the namespace of the Doe family, just "Jane" suffices to
unambiguously designate this person, while within the "global" namespace of all people, the full name must be
used.
In a similar way, hierarchical file systems organize files in directories. Each directory is a separate namespace,
so that the directories may both contain a file "jane". In computer programming, namespaces are typically
employed for the purpose of avoiding name collisions between multiple identifiers that share the same name.
source: wikipedia
Given this namespace / package name ...
We can find documentation
about that code on
godoc.org
go get github.com/goestoeleven/golangtraining
● I use godoc.org
package naming
https://golang.org/doc/code.html#PackageNames
package naming
https://golang.org/doc/effective_go.html#names
searching for packages / libraries
search godoc.org
I use this one
Review
● packages
○ packages = folders
● SDK - software development kit
● namespace
○ unique namespace of packages: everything after the “src” folder
● documentation
○ godoc.org
○ golang.org
○ godoc at terminal
● package names / paths
● searching for packages
Review Review - You’ve learned a lot
● golang is awesome ● func main()
● SHA1 ● packages
● go version ● functions vs methods
● go env ● parameters vs arguments
● go help ● expressions vs statements
● environment variables ● variable, constant, literal
○ GOPATH ● go run
○ GOROOT ● go build
● workspace ● go install
○ bin ● go get
○ pkg ○ go commands
○ src ● Go, Github, & Webstorm
■ github.com ● git
● your_user_name ○ git log
○ your_packages ○ .gitignore
■ your code ● Packages / Libraries
● .bash_profile / .bashrc ○ naming
● GO IDE’s ● namespace
○ webstorm ● documentation
○ atom ○ godoc.org
○ golang.org
○ godoc at terminal
Review Questions
Namespacing
Define namespace.
go commands
List and define the go commands you have
learned so far.