Skip to content

Commit

Permalink
fix: fix vet command and shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Feb 21, 2024
1 parent 0a13cb6 commit 528f185
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
run: |
cd ./node
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
go vet
go vet -vettool=$(which shadow)
go vet ./...
go vet -vettool=$(which shadow) ./...
- name: Install golang-migrate
run: |
Expand Down
9 changes: 6 additions & 3 deletions node/pkg/db/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,30 @@ func loadPgsqlConnectionString() string {
}

func Query(ctx context.Context, queryString string, args map[string]any) (pgx.Rows, error) {
pool, err := GetPool(ctx)
_pool, err := GetPool(ctx)
if err != nil {
return nil, err
}
pool = _pool
return query(pool, queryString, args)
}

func QueryRow[T any](ctx context.Context, queryString string, args map[string]any) (T, error) {
var t T
pool, err := GetPool(ctx)
_pool, err := GetPool(ctx)
if err != nil {
return t, err
}
pool = _pool
return queryRow[T](pool, queryString, args)
}

func QueryRows[T any](ctx context.Context, queryString string, args map[string]any) ([]T, error) {
pool, err := GetPool(ctx)
_pool, err := GetPool(ctx)
if err != nil {
return nil, err
}
pool = _pool
return queryRows[T](pool, queryString, args)
}

Expand Down
15 changes: 9 additions & 6 deletions node/pkg/db/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,40 @@ func connectRdb(ctx context.Context) (*redis.Conn, error) {
}

func Set(ctx context.Context, key string, value string, exp time.Duration) error {
rdb, err := GetRedisConn(ctx)
_rdb, err := GetRedisConn(ctx)
if err != nil {
return err
}
rdb = _rdb
return setRedis(ctx, rdb, key, value, exp)
}

func Get(ctx context.Context, key string) (string, error) {
rdb, err := GetRedisConn(ctx)
_rdb, err := GetRedisConn(ctx)
if err != nil {
return "", err
}
rdb = _rdb
return getRedis(ctx, rdb, key)
}

func Del(ctx context.Context, key string) error {
rdb, err := GetRedisConn(ctx)
_rdb, err := GetRedisConn(ctx)
if err != nil {
return err
}
rdb = _rdb
return rdb.Del(ctx, key).Err()
}

func connectToRedis(ctx context.Context, connectionInfo RedisConnectionInfo) (*redis.Conn, error) {
rdb := redis.NewClient(&redis.Options{
_rdb := redis.NewClient(&redis.Options{
Addr: connectionInfo.Host + ":" + connectionInfo.Port}).Conn()
_, rdbErr := rdb.Ping(ctx).Result()
_, rdbErr := _rdb.Ping(ctx).Result()
if rdbErr != nil {
return nil, rdbErr
}
return rdb, nil
return _rdb, nil
}

func loadRedisConnectionString() (RedisConnectionInfo, error) {
Expand Down
4 changes: 2 additions & 2 deletions node/pkg/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ func (r *Raft) sendReplyVote(to string, voteGranted bool) error {
}

func (r *Raft) sendRequestVote() error {
RequestVoteMessage := RequestVoteMessage{
requestVoteMessage := RequestVoteMessage{
Term: r.GetCurrentTerm(),
}
marshalledRequestVoteMsg, err := json.Marshal(RequestVoteMessage)
marshalledRequestVoteMsg, err := json.Marshal(requestVoteMessage)
if err != nil {
return err
}
Expand Down

0 comments on commit 528f185

Please sign in to comment.