phylocko / DailyGo

phylocko/DailyGO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is this?

This is a learning project I'm willing to grow up adding new feature every day each with some well-know library, a framework or a concept. My aim is to drive a train.

How to run this program

  1. Run the project: PORT=1600 go run cmd/web/main.go

  2. Open this url in your browser: http:/127.0.0.1:1600/


Day one

Created a web application with Gin using it's routers and templates. JSON unmarshalling and HTTP requests also has been covered.

Day two

Created a Domain/IP database with gorm. Domains are resolved on-the-fly and are stored into the database. Gin's HTTP args and POST params are covered too.

Day three

Configured logging with zap. Tuned up logging to both file and stdout, with Caller and Stacktrace options.

Day four

Context with timeout is used to limit ipinfo fetching time with an interval of 1 second. Timeout error is handeled correctly and dislayed to a user.

Day five

Learned how to deal with the Cobra. I'm using positional and keyword arguments with hierarchical command logic and validation:

> dailygo 
Dailygo — a golang learning project.

Usage:
  dailygo [command]

Available Commands:
  completion  Generate the autocompletion script
  help        Help about any command
  info        Print geoinfo of an IP address
  initdb      Init a new database
  runserver   Run the dailygo web server

Flags:
  -h, --help   help for dailygo

Use "dailygo [command] --help" for more info

Day six

Learned how to deal with the protobuf. Return IP geoinfo in a protobuf format at /api/info/pb/. Memo:

  1. Write a proto file in proto/ipinfo/ipinfo.proto
  2. Run protoc --go_out=. proto/ipinfo/ipinfo.proto
  3. Import it and use it. Gin has a special method for it!

About

phylocko/DailyGO


Languages

Language:HTML 53.1%Language:Go 46.9%