Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hiromaily/go-book-teacher

booking teacher for English lesson
https://github.com/hiromaily/go-book-teacher

docker golang homebrew redis slack travis-ci

Last synced: 14 days ago
JSON representation

booking teacher for English lesson

Awesome Lists containing this project

README

        

# go-book-teacher

[![Build Status](https://travis-ci.org/hiromaily/go-book-teacher.svg?branch=master)](https://travis-ci.org/hiromaily/go-book-teacher)
[![Coverage Status](https://coveralls.io/repos/github/hiromaily/go-book-teacher/badge.svg)](https://coveralls.io/github/hiromaily/go-book-teacher)
[![Go Report Card](https://goreportcard.com/badge/github.com/hiromaily/go-book-teacher)](https://goreportcard.com/report/github.com/hiromaily/go-book-teacher)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/hiromaily/go-book-teacher/master/LICENSE)
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/hiromaily/go-book-teacher)

Go-book-teacher is notifier for that specific teachers are available on English lesson service.
For now, only [DMM eikaiwa](https://eikaiwa.dmm.com/) 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](https://raw.githubusercontent.com/hiromaily/go-book-teacher/master/images/slack_image.png)

## Requirements
- Golang 1.15+
- Docker compose
- Redis
- [direnv](https://github.com/direnv/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)

```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](https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-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
```
3. show config info
```
$ heroku config
```
4. execute
```
$ heroku run book -toml /app/configs/heroku.toml
```
5. show logs
```
heroku logs -t
```
6. instance info
```
heroku ps
```