Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views13 pages

07 Go Build, Go Install, Import

Uploaded by

eowug
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views13 pages

07 Go Build, Go Install, Import

Uploaded by

eowug
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

go build & go install

review
two packages and two files from before ...
import
Notice how we import a package ...
Notice how we import a package ...

… and then use one of its public funcs.


Aliasing Imports
just for fun
Review
● go build
○ builds go code; if code is package main, it creates a binary executable and drops it in the package main’s
folder; if code is just a package, it builds it then throws away the binary.
● go install
○ builds and installs go code; if code is package main, it creates a binary executable and drops it in the
workspace’s bin folder; if code is a package, it builds it then drops it in the pkg folder (a file with a .a
extension)
● import
○ import path is everything after the “src” folder in your workspace
○ use the last folder in the import path to reference the package in your code
○ you can alias packages in your imports
Review Questions
import
● Search for uuid at godoc.org
● use go get to get the code for nu7hatch/gouuid
● open up finder
● locate this code
○ take a screenshot of this
● Create a file that imports this code
● alias the package as just uuid
○ take a screenshot of this

You might also like