summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2020-04-12 04:42:45 +0700
committerShulhan <m.shulhan@gmail.com>2020-04-12 04:42:45 +0700
commit8e2aaf2df151f61a874bb7a62929afb005fa2abd (patch)
tree3497f604013d52b7f9a3c38335cf77661b388c44
parent9cf57fc952e4161c8e7fc5c9de8869d3137acb20 (diff)
downloadkamusku-8e2aaf2df151f61a874bb7a62929afb005fa2abd.tar.xz
all: fix and suppress linter warnings
-rw-r--r--api_client_test.go7
-rw-r--r--cmd/bot-kbbi/main.go10
-rw-r--r--cmd/kbbi/main.go5
-rw-r--r--cmd/www-kbbi/main.go5
-rw-r--r--kbbi.go1
-rw-r--r--kbbi_test.go7
-rw-r--r--server.go3
-rw-r--r--telegram_bot.go2
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 <b>` + update.Message.From.FirstName + `</b>,
Untuk mencari definisi kata ketikan perintah <code>/definisi</code> diikuti dengan spasi dan kata yang ingin dicari. Pisahkan kata dengan koma untuk mencari lebih dari satu kata.