Skip to content

Commit 731e2d7

Browse files
committed
ci: add go lint
1 parent 6300a8f commit 731e2d7

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: '~1.23'
19+
20+
- name: Run linter
21+
uses: golangci/golangci-lint-action@v6
22+
with:
23+
version: v1.61

pkg/backup.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ package pkg
2727

2828
import (
2929
"bytes"
30+
"errors"
3031
"fmt"
3132
"github.com/jkaninda/encryptor"
3233
"github.com/jkaninda/go-storage/pkg/local"
@@ -388,7 +389,7 @@ func listDatabases(db dbConfig) ([]string, error) {
388389
databases := []string{}
389390
// Create the mysql client config file
390391
if err := createMysqlClientConfigFile(db); err != nil {
391-
return databases, fmt.Errorf(err.Error())
392+
return databases, errors.New(err.Error())
392393
}
393394
utils.Info("Listing databases...")
394395
// Step 1: List all databases

pkg/helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package pkg
2626

2727
import (
2828
"bytes"
29+
"errors"
2930
"fmt"
3031
goutils "github.com/jkaninda/go-utils"
3132
"github.com/jkaninda/mysql-bkup/utils"
@@ -70,14 +71,13 @@ func deleteTemp() {
7071
func testDatabaseConnection(db *dbConfig) error {
7172
// Create the mysql client config file
7273
if err := createMysqlClientConfigFile(*db); err != nil {
73-
return fmt.Errorf(err.Error())
74+
return errors.New(err.Error())
7475
}
7576
utils.Info("Connecting to %s database ...", db.dbName)
7677
// Set database name for notification error
7778
utils.DatabaseName = db.dbName
7879

7980
// Prepare the command to test the database connection
80-
//cmd := exec.Command("mariadb", "-h", db.dbHost, "-P", db.dbPort, "-u", db.dbUserName, db.dbName, "-e", "quit")
8181
cmd := exec.Command("mariadb", fmt.Sprintf("--defaults-file=%s", mysqlClientConfig), db.dbName, "-e", "quit")
8282
// Capture the output
8383
var out bytes.Buffer

0 commit comments

Comments
 (0)