Skip to content

Commit

Permalink
feat: Add GitHub Action for Go linting (#18)
Browse files Browse the repository at this point in the history
* feat: Add GitHub Action for Go linting

* fix

* Update README to remove outdated informatio
  • Loading branch information
strahe authored Sep 24, 2024
1 parent b6cfed5 commit ede1376
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 23 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: golangci-lint
on:
push:
pull_request:

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- run: make ffi-deps
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
args: --timeout=10m
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
unexport GOFLAGS

GOFLAGS=-ldflags="-s -w"
GO_BUILD_IMAGE?=golang:1.22.3
VERSION?=$(shell git describe --always --tag --dirty)
docker_sanitized_version=$(shell echo ${VERSION} | sed 's:/:-:g')
Expand Down
8 changes: 4 additions & 4 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ OPTIONS:
使用Docker运行服务:
```shell
docker run -d --name extend \
-p 8000:8000
-e FULLNODE_API_INFO="lotus api info"
-v /path/to/extend:/app
gh-efforts/extend:latest run --listen 0.0.0.0:8000 --db /app/extend.db
-p 8000:8000 \
-e FULLNODE_API_INFO="lotus api info" \
-v /path/to/extend:/app \
ghcr.io/strahe/extend:latest run --listen 0.0.0.0:8000 --db /app/extend.db
```
### 开启鉴权 (可选)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ Get help
Run the service using Docker:
```shell
docker run -d --name extend \
-p 8000:8000
-e FULLNODE_API_INFO="lotus api info"
-v /path/to/extend:/app
gh-efforts/extend:latest run --listen 0.0.0.0:8000 --db /app/extend.db
-p 8000:8000 \
-e FULLNODE_API_INFO="lotus api info" \
-v /path/to/extend:/app \
ghcr.io/strahe/extend:latest run --listen 0.0.0.0:8000 --db /app/extend.db
```
### Enable authentication (optional)
Expand Down
6 changes: 2 additions & 4 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ func authMiddleware(secret []byte) mux.MiddlewareFunc {
return authHandler
}

const (
userCtxKey = "auth_user"
)
type userCtxKey struct{}

func WithAuthUser(ctx context.Context, user string) context.Context {
return context.WithValue(ctx, userCtxKey, user)
return context.WithValue(ctx, userCtxKey{}, user)
}
9 changes: 3 additions & 6 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var authCreateTokenCmd = &cli.Command{
var d time.Duration
if cctx.IsSet("expiry") {
expiry := cctx.Timestamp("expiry")
d = expiry.Sub(time.Now())
d = time.Until(*expiry)
}

token, err := authNew([]byte(cctx.String("secret")),
Expand Down Expand Up @@ -212,11 +212,8 @@ func MonitorShutdown(handlers ...node.ShutdownHandler) <-chan struct{} {
out := make(chan struct{})

go func() {
select {
case sig := <-sigCh:
log.Warnw("received shutdown", "signal", sig)
}

sig := <-sigCh
log.Warnw("received shutdown", "signal", sig)
log.Warn("Shutting down...")

// Call all the handlers, logging on failure and success.
Expand Down
8 changes: 4 additions & 4 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type RequestStatus string

const (
RequestStatusCreated RequestStatus = "created"
RequestStatusPending = "pending"
RequestStatusFailed = "failed"
RequestStatusPartfailed = "partfailed"
RequestStatusSuccess = "success"
RequestStatusPending RequestStatus = "pending"
RequestStatusFailed RequestStatus = "failed"
RequestStatusPartfailed RequestStatus = "partfailed"
RequestStatusSuccess RequestStatus = "success"
)

// Request represents a request in the system.
Expand Down
2 changes: 1 addition & 1 deletion service.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ loopParams:
return result, nil
}
// join errors as one error
return result, fmt.Errorf(strings.Join(errMsgs, ";\n"))
return result, fmt.Errorf("%s", strings.Join(errMsgs, ";\n"))
}

type extendResult struct {
Expand Down

0 comments on commit ede1376

Please sign in to comment.