This repo contains my exercises and experiments in Golang. If you already have Golang environment setup (e.g. $GOPATH
):
- To get the whole repo, run
go get github.com/davidfeng88/goex/...
. - To see the doc in browser: first run
godoc -http=:999
, then in browser go tohttp://localhost:999/pkg/github.com/davidfeng88/goex/
.
A package used in John Graham-Cumming's Introduction to Go Programming course. It demostrates the basics of Golang, including types, slices, interfaces, strings
, fmt
, bufio
, etc.
- To run the tests:
go test github.com/davidfeng88/goex/poetry
(Use-v
for verbose)
Also a package used in John Graham-Cumming's Introduction to Go Programming course. It uses the poetry
package, and demostrates the usages of struct, encoding/json
, flag
, log
, net/http
, strconv
, sync
, time
, etc. The server loads config file and poem file, and serves the poem.
To run the server:
go install github.com/davidfeng88/goex/poetryserver
- Copy the sample config file
config
, and the poem fileperfect_woman
to your$GOPATH
- Whe working directory is
$GOPATH
, runbin/poetryserver
. You should see server logs in terminal. - In terminal, run
curl http://127.0.0.1:8088/poem?name=perfect_woman
or go tohttp://localhost:8088/poem?name=perfect_woman
in browser.
A package used in John Graham-Cumming's Intermediate Go Programming course. It uses channels to queue and distribute work, and collate results.
A package used in John Graham-Cumming's Intermediate Go Programming course. It uses the task
package and fetches multiple URLs concurrently.
To try it out:
go install github.com/davidfeng88/goex/taskdemo
- Whe working directory is
$GOPATH
,echo "https://google.com" | bin/taskdemo
should returntrue
, whileecho "https://google.com/foo" | bin/taskdemo
should returnfalse
. - Copy the sample URL file
urls
to your$GOPATH
. Runbin/taskdemo -count=1 < src/github.com/davidfeng88/goex/taskdemo/urls
. Change the count argument to see the difference.
Exercises from the Go Programming Language.