Giter VIP home page Giter VIP logo

goexamples's Introduction

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

goexamples's People

Contributors

junxie6 avatar junhsieh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.