go-book-teacher

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2021 License: MIT

README

go-book-teacher

Build Status Coverage Status Go Report Card MIT License Deploy

Go-book-teacher is notifier for that specific teachers are available on English lesson service.
For now, only DMM eikaiwa is expected.

This project has started since 2016 to study Golang and code is quite messy. Now it's under refactoring.

Console
----------- Rita M / Portugal / 7093 -----------
----------- Gagga / Serbia / 5252 -----------
----------- Kaytee / Serbia / 7646 -----------
----------- Milica J / Serbia / 6294 -----------
----------- Marine / France / 8519 -----------
----------- Lavinija / Serbia / 5656 -----------
2017-07-06 20:30:00
2017-07-07 16:00:00
2017-07-07 18:00:00
2017-07-07 18:30:00
----------- Aleksandra S / Serbia / 6214 -----------
----------- Jekica / Serbia / 4806 -----------
----------- Yovana / Serbia / 6550 -----------
2017-07-07 03:30:00
2017-07-07 04:00:00
2017-07-07 04:30:00
----------- Olivera V / Serbia / 5380 -----------
----------- Emilia / Serbia / 2464 -----------
----------- Indre / Lithuania / 3486 -----------
----------- Joxyly / Serbia / 4808 -----------
----------- Milica Ml / Serbia / 4107 -----------
Slack

slack

Requirements

  • Golang 1.15+
  • Docker compose
    • Redis
  • direnv for MacOS user

Installation

for MacOS user
$ brew install hiromaily/tap/go-book-teacher

# 
# config file is installed in /usr/local/etc/book-teacher/book-teacher.toml
# modify `book-teacher.toml` if settings wanna be changed
#
# json file is installed in /usr/local/etc/book-teacher/book-teacher.json
# add your teacher's ID/Name/Nationality to `book-teacher.json`

# run
$ book-teacher
for development
# clone
$ git clone https://github.com/hiromaily/go-book-teacher.git

# setup config file
$ cp configs/default.example.toml configs/default.toml
# and modify `configs/default.toml` as you want

# setup your favorite teacher's information
$ cp configs/teacher/default.example.json configs/teacher/default.json
# and modify `configs/teacher/default.json` as you want

# setup .envrc
$ cp example.envrc .envrc
# and modify `.envrc` as you want

# build
$ make build

# run
book

Usage

Usage: book [options...]

Options:
  -json      Json file path for teacher information
  -toml      Toml file path for config
  -day       range of schedule to get teacher's availability: 0: all day, 1:today, 2: tomorrow
  -v         show version

e.g.
 $ book -day 1
 $ book -h      # show help

Environment valuables

  • envrc is used for MacOS user, please install direnv](https://github.com/direnv/direnv)
  • encryption is used for secret value in config files.
  • secret value can be encrypted/decrypted by tools (see Makefile)
.PHONY: tool-encode
tool-encode:
	go run ./tools/encryption/ -encode important-password

.PHONY: tool-decode
tool-decode:
	go run ./tools/encryption/ -decode o5PDC2aLqoYxhY9+mL0W/IdG+rTTH0FWPUT4u1XBzko=
NAME Value
GO_BOOK_CONF default config file path
GO_BOOK_JSON default teacher info json file path
ENC_KEY 16byte_string_xx
ENC_IV 16byte_string_xx

deploy on heroku

modification in go.mod

add +heroku goVersion go1.x

// +heroku goVersion go1.15
go 1.15
install

Heroku Buildpack for Go

#
$ heroku create book-teacher --buildpack https://github.com/heroku/heroku-buildpack-go.git
$ heroku addons:create heroku-redis:hobby-dev
$ heroku addons:create scheduler:standard

## Environment variable
$ heroku config:add 'ENC_KEY=xxxxxxxxxxxxxxxx'
$ heroku config:add 'ENC_IV=xxxxxxxxxxxxxxxx'
$ heroku config:add GO_BOOK_CONF=/app/configs/heroku.toml
$ heroku config:add GO_BOOK_JSON=/app/configs/teacher/default.example.json
deploy
$ git push heroku master
get information
  1. access to dashboard https://dashboard.heroku.com/apps
  2. click app book-teacher
  3. redis status
$ heroku addons | grep heroku-redis
$ heroku redis:cli --confirm book-teacher
  1. show config info
$ heroku config
  1. execute
$ heroku run book -toml /app/configs/heroku.toml
  1. show logs
heroku logs -t
  1. instance info
heroku ps

Directories

Path Synopsis
cmd
pkg
tools

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL