chore: go imports and add github workflow for lint
Signed-off-by: ashing <axingfly@gmail.com>
This commit is contained in:
parent
60d84625af
commit
07cd943fda
|
|
@ -0,0 +1,51 @@
|
||||||
|
name: Lint Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- release/**
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- release/**
|
||||||
|
permissions: read-all
|
||||||
|
jobs:
|
||||||
|
gofmt:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Go Environment
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.20.3'
|
||||||
|
- name: Run gofmt Check
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
diffs=`gofmt -l .`
|
||||||
|
if [[ -n $diffs ]]; then
|
||||||
|
echo "Files are not formatted by gofmt:"
|
||||||
|
echo $diffs
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
golint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Go Environment
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.20.3'
|
||||||
|
- name: Install jq
|
||||||
|
run: sudo apt install -y jq
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
- name: Download golangci-lint
|
||||||
|
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
|
||||||
|
- name: Run Golang Linters
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
PATH=${PATH}:$(go env GOPATH)/bin make lint
|
||||||
4
Makefile
4
Makefile
|
|
@ -22,3 +22,7 @@ test:
|
||||||
go tool cover -html=./sdk.cover -o ./sdk.html
|
go tool cover -html=./sdk.cover -o ./sdk.html
|
||||||
fmt:
|
fmt:
|
||||||
find ./ -name "*.go" | xargs gofmt -w
|
find ./ -name "*.go" | xargs gofmt -w
|
||||||
|
|
||||||
|
lint: ## Apply go lint check
|
||||||
|
@golangci-lint run --timeout 10m ./...
|
||||||
|
.PHONY: lint
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package chatbot
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,19 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/handler"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/handler"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/logger"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/logger"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/plugin"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/plugin"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/utils"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/utils"
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,11 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package event
|
package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/logger"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package event
|
package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/utils"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/utils"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package event
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/logger"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/logger"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ package event
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/client"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/client"
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/event"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/event"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package logger
|
package logger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package payload
|
package payload
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ package payload
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package payload
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package payload
|
package payload
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package plugin
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
go install github.com/incu6us/goimports-reviser/v2@latest
|
||||||
|
|
||||||
|
PROJECT_NAME=github.com/open-dingtalk/dingtalk-stream-sdk-go
|
||||||
|
|
||||||
|
find . -name '*.go' -print0 | while IFS= read -r -d '' file; do
|
||||||
|
goimports-reviser -file-path "$file" -project-name "$PROJECT_NAME"
|
||||||
|
done
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetFirstLanIP(t *testing.T) {
|
func TestGetFirstLanIP(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue