This is homework about implementing echo line bot. The line bot will echo your text message.
The following are the packages used in this Golang project.
- gin-gonic: as http framework
- go-migrate: to create mongo collections
- cobra: to create subcommands
- viper: to read environment variables and config file.
- golangci: to check the style
Before starting this program, please make sure that your docker is running.
-
Get the line channel token and secret from Line Developer Console.
-
Get token and secret from step 1 and set
LINE_CHANNEL_SECRET
,LINE_CHANNEL_TOKEN
as environment variable.
export LINE_CHANNEL_SECRET=YOUR_CHANNEL_SECRET
export LINE_CHANNEL_TOKEN=YOUR_CHANNEL_TOKEN
- Run line bot server using docker-compose
make dc.run
The server serve on 9999
port.
The api endpoint:
http://URL:9999/linebot/webhook
http://URL:9999/linebot/user/${userID}?count=${size}&after=${timestamp} -> list the user image by userID
- Use ngrok to expose to public network and past the endpoint in Line Developer Console.
ngork http 9999
example: If ngrok provided url is https://XXXX.jp.ngrok.io
, You need to paste follwing webhook url to Line Developer Console
https://XXXX.jp.ngrok.io//linebot/webhook
- Chat with line, the server will echo your text message.
This project uses golangci to check the style.
- Check golang coding style in docker
make d.lint
- Check golang coding style in host machine (need to install golangci-lint first)
make lint
- Build docker image for line bot server
make image
- Instrument the service by opentelemetry.
- Use Kubernetes to manage it instead of docker-compose.
- Write test for core logic.