aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--cli.go4
-rw-r--r--cli_test.go9
-rw-r--r--cmd/gotp/main.go4
-rw-r--r--gotp.go8
5 files changed, 22 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 3cfbd13..25cbaba 100644
--- a/Makefile
+++ b/Makefile
@@ -3,12 +3,18 @@
.PHONY: all test build install serve-doc
-all: test build
+all: test lint build
test:
CGO_ENABLED=1 go test -race -failfast -coverprofile=cover.out ./...
go tool cover -html=cover.out -o cover.html
+.PHONY: lint
+lint:
+ -revive ./...
+ -fieldalignment ./...
+ -shadow ./...
+
build:
mkdir -p _sys/usr/bin/
go build -o _sys/usr/bin/ ./cmd/...
diff --git a/cli.go b/cli.go
index 446f757..3d1911b 100644
--- a/cli.go
+++ b/cli.go
@@ -19,13 +19,17 @@ import (
"golang.org/x/term"
)
+// Readme embed the README.md, rendered in "gotp help".
+//
//go:embed README.md
var Readme string
+// Cli define the command line interface for gotp program.
type Cli struct {
cfg *config
}
+// NewCli create and initialize new CLI for gotp program.
func NewCli() (cli *Cli, err error) {
var (
logp = `NewCli`
diff --git a/cli_test.go b/cli_test.go
index 5eeffd4..8d0218c 100644
--- a/cli_test.go
+++ b/cli_test.go
@@ -198,10 +198,11 @@ func TestCli_SetPrivateKey(t *testing.T) {
}
var (
- gotLabels []string = cli.List()
- label string
- issuer *Issuer
- got bytes.Buffer
+ gotLabels = cli.List()
+
+ label string
+ issuer *Issuer
+ got bytes.Buffer
)
for _, label = range gotLabels {
diff --git a/cmd/gotp/main.go b/cmd/gotp/main.go
index 71e5226..c0fbece 100644
--- a/cmd/gotp/main.go
+++ b/cmd/gotp/main.go
@@ -149,8 +149,8 @@ func doAdd(cli *gotp.Cli, args []string) {
func doGenerate(cli *gotp.Cli, args []string) {
var (
- label = args[1]
- n int = 1
+ label = args[1]
+ n = 1
listOtp []string
otp string
diff --git a/gotp.go b/gotp.go
index 0c44adf..51ed63b 100644
--- a/gotp.go
+++ b/gotp.go
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info>
// SPDX-License-Identifier: GPL-3.0-or-later
+// Package gotp core library for building gotp CLI.
package gotp
import (
@@ -24,15 +25,14 @@ const (
providerNameAegis = `aegis`
)
-var (
- Version = `0.3.1`
-)
+// Version define the latest version of this module and gotp CLI.
+var Version = `0.3.1`
// normalizeLabel convert non alpha number, hyphen, underscore, or period
// characters into `-`.
func normalizeLabel(in string) (out string) {
var (
- replacement rune = '-'
+ replacement = '-'
buf strings.Builder
r rune