From 8e2aaf2df151f61a874bb7a62929afb005fa2abd Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 12 Apr 2020 04:42:45 +0700 Subject: all: fix and suppress linter warnings --- api_client_test.go | 7 ++++++- cmd/bot-kbbi/main.go | 10 +++++++++- cmd/kbbi/main.go | 5 ----- cmd/www-kbbi/main.go | 5 ++++- kbbi.go | 1 - kbbi_test.go | 7 ------- server.go | 3 ++- telegram_bot.go | 2 +- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/api_client_test.go b/api_client_test.go index ea63997..f2e9a87 100644 --- a/api_client_test.go +++ b/api_client_test.go @@ -83,7 +83,12 @@ func TestApiClient_CariDefinisi_online(t *testing.T) { words: []string{"mengeja", "eja"}, exp: DefinisiResponse{ "mengeja": testKataMengeja, - "eja": testKataEja, + "eja": &Kata{ + Definisi: []*DefinisiKata{{ + Isi: "lafal huruf satu demi satu", + Kelas: []string{"Verba: kata kerja"}, + }}, + }, }, }} diff --git a/cmd/bot-kbbi/main.go b/cmd/bot-kbbi/main.go index 66b2edf..91c2552 100644 --- a/cmd/bot-kbbi/main.go +++ b/cmd/bot-kbbi/main.go @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +// Program bot-kbbi adalah Telegram Bot yang melayani pencarian definisi kata +// menggunakan perintah pesan di Telegram. +// package main import ( @@ -27,9 +31,13 @@ func main() { log.Println(err) } }() - defer tgbot.Stop() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) <-c + + err = tgbot.Stop() + if err != nil { + log.Println(err) + } } diff --git a/cmd/kbbi/main.go b/cmd/kbbi/main.go index 3b07c36..09b3a92 100644 --- a/cmd/kbbi/main.go +++ b/cmd/kbbi/main.go @@ -17,11 +17,6 @@ import ( "github.com/shuLhan/kbbi" ) -const ( - configDir = "kbbi" - cookieFile = "cookie" -) - func main() { var ( isListKataDasar bool diff --git a/cmd/www-kbbi/main.go b/cmd/www-kbbi/main.go index 7a3933a..370ed16 100644 --- a/cmd/www-kbbi/main.go +++ b/cmd/www-kbbi/main.go @@ -29,5 +29,8 @@ func main() { signal.Notify(c, os.Interrupt) <-c - server.Shutdown() + err = server.Shutdown() + if err != nil { + log.Println(err) + } } diff --git a/kbbi.go b/kbbi.go index 897e96d..c289722 100644 --- a/kbbi.go +++ b/kbbi.go @@ -21,7 +21,6 @@ const ( attrNameClass = "class" attrNameHref = "href" - attrNameName = "name" attrNameTitle = "title" attrNameValue = "value" diff --git a/kbbi_test.go b/kbbi_test.go index 7d9a783..a9250aa 100644 --- a/kbbi_test.go +++ b/kbbi_test.go @@ -29,13 +29,6 @@ var ( }, }}, } - - testKataEja = &Kata{ - Definisi: []*DefinisiKata{{ - Isi: "lafal huruf satu demi satu", - Kelas: []string{"Verba: kata kerja"}, - }}, - } ) func TestMain(m *testing.M) { diff --git a/server.go b/server.go index aea5982..e3ed460 100644 --- a/server.go +++ b/server.go @@ -5,6 +5,7 @@ package kbbi import ( + "context" "fmt" "log" stdhttp "net/http" @@ -109,7 +110,7 @@ func (server *Server) Start() (err error) { // Shutdown the HTTP server and save the cache for future use. // func (server *Server) Shutdown() (err error) { - err = server.http.Shutdown(nil) + err = server.http.Shutdown(context.TODO()) server.stopped <- true diff --git a/telegram_bot.go b/telegram_bot.go index 0f18729..a32fa17 100644 --- a/telegram_bot.go +++ b/telegram_bot.go @@ -16,7 +16,6 @@ import ( const ( defAddress = ":1928" - commandBantuan = "bantuan" commandDefinisi = "definisi" commandStart = "start" ) @@ -123,6 +122,7 @@ func (tgbot *TelegramBot) handleCommandDefinisi(update bot.Update) { // handleCommandStart handle the "/start" command by welcoming the user. // func (tgbot *TelegramBot) handleCommandStart(update bot.Update) { + //nolint: lll text := `Selamat datang ` + update.Message.From.FirstName + `, Untuk mencari definisi kata ketikan perintah /definisi diikuti dengan spasi dan kata yang ingin dicari. Pisahkan kata dengan koma untuk mencari lebih dari satu kata. -- cgit v1.3