Categorygithub.com/junhsieh/goexamples
module
0.0.0-20210908032526-acdd3160140b
Repository: https://github.com/junhsieh/goexamples.git
Documentation: pkg.go.dev

# README

Go Examples

Some useful examples for Go golang

Show how to use the third party Go middlewares and how to implement a custom Go middleware

# cd httpmuxmiddleware

# openssl req -newkey rsa:2048 -nodes -subj "/C=CA/ST=British Columbia/L=Vancouver/O=My Company Name/CN=erp.local" -keyout erp.local.key -out erp.local.csr

# go run httpmuxmiddleware/httpmuxmiddleware.go

Run a web server and Transparently gzip the response body

# go run webgzip/webgzip.go

Run a web server and serve static files

# go run webstaticfile/webstaticfile.go

Convert a map to a JSON string

# go run convmapjson/convmapjson.go

Convert a struct to a JSON string

# go run convstructjson/convstructjson.go

Decode JSON string

# go run decodejson/decodejson.go

Two factor authentication TOTP (Time-based One Time Password) example

# go run twofactortotpsec51/twofactortotpsec51.go

Then, go to:

http://127.0.0.1/qr

http://127.0.0.1/v

More info: https://github.com/sec51/twofactor

Two factor authentication TOTP (Time-based One Time Password) example

# go run twofactortotppquerna/twofactortotppquerna.go

Then, go to:

http://127.0.0.1/qr

http://127.0.0.1/v

More info: https://github.com/pquerna/otp

JSON Web Token (JWT)

# go run jsonwebtoken/jsonwebtoken.go

Then, go to http://127.0.0.1/

More info: https://github.com/dgrijalva/jwt-go

Date time format conversion

# go run datetimeconv/datetimeconv.go 127.0.0.1

Loop through golang struct

# go run loopthroughstruct/loopthroughstruct.go

HTML template

# go run htmltemplate/htmltemplate.go

Multiple HTML templates and passing the variables to the inner templates

# go run htmltemplatemultiple/htmltemplatemultiple.go

Print Message

# go run printmessage/printmessage.go

Read arguments from console

# go run consoleargument/consoleargument.go test.txt A B C

Connect to MySQL

# go run connectmysql/connectmysql.go

Connect to MySQL (better)

# go run connectmysqlmodel/connectmysqlmodel.go

HTTP Post

# go run httppost/httppost.go

Run an external command

# go run runexternalcommand/runexternalcommand.go

# Packages

No description provided by the author
Chat is a server that lets clients chat with each other.
No description provided by the author
Chat is a server that lets clients chat with each other.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Reference: https://appliedgo.net/mapreduce/ https://play.golang.org/p/cipGuzMNT3.
No description provided by the author
No description provided by the author
Display each byte read while reading the data Reference: https://stackoverflow.com/questions/22421375/how-to-print-the-bytes-while-the-file-is-being-downloaded-golang.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Reference: https://gobyexample.com/sha1-hashes.
Reference: https://golang.org/pkg/sort/#example_Interface.
No description provided by the author
Reference: https://groups.google.com/forum/#!topic/golang-nuts/n_By5xPzDho/discussion https://play.golang.org/p/RXFN2ACuNC.
No description provided by the author
Clock is a TCP server that periodically writes the time.
[Timers](timers) are for when you want to do something once in the future - _tickers_ are for when you want to do something repeatedly at regular intervals.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author