0% found this document useful (0 votes)
2 views

09+resources,+help,+variadic,+BNF,+reading+documentation

Uploaded by

eowug
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

09+resources,+help,+variadic,+BNF,+reading+documentation

Uploaded by

eowug
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 95

Documentation & Variadic

resources, help, variadic, BNF, documentation


● getting help
○ go help
■ go help [command]

Preview ■

go help [topic]
go help examples:
● go help env
● learning golang from golang.org ○ variadic
○ http://golang.org/doc/ ■ ...
■ https://golang.org/doc/install ○ BNF / EBNF
■ https://golang.org/ref/spec ■ Backus Naur Form
■ https://tour.golang.org/welcome/1 ■ Extended Backus
■ https://golang.org/doc/code.html Naur Form
■ https://golang.org/doc/effective_go.html ● go help packages
■ https://blog.golang.org/ ● go help build
● go help install
○ documentation
■ godoc.org
● “imported by” example code
■ golang.org
■ godoc
● google: golang godoc
○ golang.org/x/tools/cmd/godoc
● godoc -src fmt Println
● godoc -src fmt
● godoc -http=:6060
● godoc -html fmt
● godoc -html fmt Println
● godoc -q Reader
● godoc -q Writer
● godoc -q rand
■ close server
● ctrl + c
■ http://go-search.org/
resources
https://www.golang-book.com/
https://gobyexample.com/
https://www.manning.com/books/go-in-action
https://golang.org/
https://tour.golang.org/welcome/1
http://golangweekly.com/
learning golang
from golang.org
tall
ins
e go ...
iv t
f ect st ye
ef t ju
o
tn
bu
c
pe
ges
g ua
lan
f go this
r o aw
tou dy s
a
alre
we
go
w rite
o
ow t code
h
o w … go
N tive
ec
eff

https://golang.org/doc/effective_go.html
g
o blo
th eg

https://golang.org/doc/#articles
getting help
go help
review
Why doesn’t this work?
d ]
a n
m m
[ c o ]
lp p i c
h e [ t o
go help
go

We already saw this in


“01 Getting Started”
review
use “go help [command]” at the terminal
to learn more about the env command
What does this mean?

Go Variadic
To understand what this means We
bo nee
th
BN d t o
F & und
va ers
ria tan
dic d

Go Variadic
bnf
Backus-Naur Form
Backus Naur Form
● Udacity Grammar
● Udacity BNF
○ and on udacity:
■ grammar
■ BNF
■ BNF Quiz
● 0612 TV BNF
● Wikipedia BNF
● Wikipedia EBNF
Backus Naur Form
● Udacity Grammar
● Udacity BNF
○ and on udacity:
■ grammar
■ BNF
■ BNF Quiz
● 0612 TV BNF
● Wikipedia BNF
● Wikipedia EBNF
variadic
...params
args...

Go Variadic
variadic

Multiple parameters

Multiple arguments

Go Variadic
exercise
use “go help [topic]” at the terminal
to learn about packages
exercise
can you find online
the same information we found
using “go help [topic]” at the terminal
to learn about packages?
ot
n
d id exercise
I
can you find online
the same information we found
using “go help [topic]” at the terminal
to learn about packages?
exercise
can you find this online?
exercise
can you find this online?
ot
n
d id
I
some information is only available
at the terminal, it seems
finding information sometimes requires
digging around
exercise
use “go help [command]” at the terminal
to learn more about the build command
exercise
use “go help [command]” at the terminal
to learn more about the install command
documentation
godoc.org
vs
golang.org
vs
godoc

what’s the difference?


godoc.org
documentation for packages written by anyone, including documentation for official SDK

godoc
documentation at TERMINAL for packages written by anyone, including documentation for official SDK

golang.org
documentation for official SDK only
b oth e
, d
w are en co
b e a writt
t -
t, bu oorly d.
g rea nd p foun
s a e
h is i itten ill b
T wr w
ll-
we
documentation
godoc
o c
d I found this by googling: golang godoc
go
c
do
go
d/

ut
cm
ols/
/to

bo
/x
rg
.o
ng
a g/
go
l a

r e do
c .o
r

o tp
://
go

m ht

Things sometimes migrate from tools to the standard SDK library

https://blog.golang.org/go1.5
exercise
can you find this at
the terminal?
exercise
can you find this at
ot
the terminal?
n
d id
I
exercise
just out of curiosity,
can you find more tools starting from this URL?
http://godoc.org/golang.org/x/tools/cmd/godoc
exercise
use “godoc package [name ...]”
with multiple names
exercise
use “godoc package [name ...]”
with multiple names
What are the names: functions or methods?
l
s tm
od cts
.h
m eth -st
ru
m/
n
s-o
. co eth
od
m ple /0 6/m
xa /20
11
ye
/g ob ot.c
om

p s:/ log
sp
htt rials
.b

gt uto
lan
/go
http
:/

exercise
use “godoc package [name ...]”
with multiple names
What are the names: functions or methods?
exercise
use “go doc package [name ...]”
with one name
reminder: same as finding it at godoc.org (or golang.org)

but this gives us some code to look at:


exercise
use “godoc [flag] package [name ...]” with a flag
to show you at the terminal an example of the code used for
fmt Println
godoc vs godoc.org
exercise
use “godoc [flag] package [name ...]”
to show you at the terminal the package
fmt
You don’t need to specify method names
because names [ name …] are optional
exercise
find on godoc.org
the package
fmt
a l
in
rm
te g
he r
t t c .o
a d o
n g o
t hi t g
e a
m et
sa g
h e y ou
tt as
ge
exercise
use “godoc [flag] package [name ...]” with a flag
then lookup fmt package documentation in a browser at
localhost:6060
close server
at terminal: ctrl + c
exercise
use “godoc [flag] package [name ...]” with a flag
to print html for the fmt package in the terminal
exercise
use “godoc [flag] package [name ...]” with a flag
to print html for the fmt Println method in the terminal
exercise
use “godoc [flag] package [name ...]” with a flag
to find every “Reader” in the documentation
exercise
use “godoc [flag] package [name ...]” with a flag
to find every “Writer” in the documentation
exercise
use “godoc [flag] package [name ...]” with a flag
to find package that gives a random number
(search for “rand”)
webstorm cmd + click
reminder:
cmd+click in webstorm
allows you to click on a package / method
to view the source code of that package / method
If I hold down “cmd” and click fmt ...
I am taken to the source code!
Do you know the answer
to this question now?
What’s the difference between
godoc.org
golang.org
godoc at terminal
go help [command]
go help [topic]
Review Questions
variadic
Define variadic.
What is the difference between code like this:

And like this:


BNF
Define BNF
EBNF
Create your own example using EBNF
godoc
● Launch a server showing docs at localhost
godoc
● Using the terminal, find every “Reader” in the
documentation

You might also like