Skip to content

Commit

Permalink
feat: makefile support go sort imports (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronething committed Sep 7, 2023
1 parent 24d40ab commit f397318
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 17 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ build-linux-arm:
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -o chatgpt-dingtalk main.go

lint:
env GOGC=25 golangci-lint run --fix -j 8 -v ./...
env GOGC=25 golangci-lint run --fix -j 8 -v ./...

goimports:
@bash ./scripts/goimports-reviser.sh
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"sync"
"time"

"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
"gopkg.in/yaml.v2"

"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
)

type Credential struct {
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import (
"strings"
"time"

"github.com/gin-gonic/gin"
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
"github.com/open-dingtalk/dingtalk-stream-sdk-go/client"

"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
"github.com/eryajf/chatgpt-dingtalk/pkg/process"
"github.com/eryajf/chatgpt-dingtalk/public"
"github.com/gin-gonic/gin"
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
"github.com/open-dingtalk/dingtalk-stream-sdk-go/client"
)

func init() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cache/user_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package cache
import (
"time"

"github.com/eryajf/chatgpt-dingtalk/config"
"github.com/patrickmn/go-cache"

"github.com/eryajf/chatgpt-dingtalk/config"
)

// UserServiceInterface 用户业务接口
Expand Down
3 changes: 2 additions & 1 deletion pkg/chatgpt/chatgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"net/url"
"time"

"github.com/eryajf/chatgpt-dingtalk/public"
openai "github.com/sashabaranov/go-openai"

"github.com/eryajf/chatgpt-dingtalk/public"
)

type ChatGPT struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/chatgpt/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"strings"
"time"

"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
"github.com/pandodao/tokenizer-go"
openai "github.com/sashabaranov/go-openai"

"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
"github.com/eryajf/chatgpt-dingtalk/public"
openai "github.com/sashabaranov/go-openai"
)

var (
Expand Down
1 change: 1 addition & 0 deletions pkg/chatgpt/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/avast/retry-go"

"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
"github.com/eryajf/chatgpt-dingtalk/public"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/db/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package db
import (
"os"

"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
"github.com/glebarez/sqlite"
"gorm.io/gorm"

"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
)

// 全局数据库对象
Expand Down
3 changes: 2 additions & 1 deletion pkg/dingbot/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/eryajf/chatgpt-dingtalk/config"
"io"
"mime/multipart"
"net/http"
url2 "net/url"
"sync"
"time"

"github.com/eryajf/chatgpt-dingtalk/config"
)

// OpenAPI doc: https://open.dingtalk.com/document/isvapp/upload-media-files
Expand Down
3 changes: 2 additions & 1 deletion pkg/dingbot/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package dingbot

import (
"bytes"
"github.com/eryajf/chatgpt-dingtalk/config"
"image"
"image/color"
"image/png"
"os"
"testing"

"github.com/eryajf/chatgpt-dingtalk/config"
)

func TestUploadMedia_Pass_WithValidConfig(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/process/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package process
import (
"context"
"fmt"
"github.com/eryajf/chatgpt-dingtalk/public"
"strings"

"github.com/solywsh/chatgpt"

"github.com/eryajf/chatgpt-dingtalk/pkg/db"
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
"github.com/solywsh/chatgpt"
"github.com/eryajf/chatgpt-dingtalk/public"
)

// ImageGenerate openai生成图片
Expand Down
3 changes: 2 additions & 1 deletion pkg/process/process_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"strings"
"time"

"github.com/solywsh/chatgpt"

"github.com/eryajf/chatgpt-dingtalk/pkg/db"
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
"github.com/eryajf/chatgpt-dingtalk/public"
"github.com/solywsh/chatgpt"
)

// ProcessRequest 分析处理请求逻辑
Expand Down
3 changes: 2 additions & 1 deletion public/public.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package public

import (
"github.com/sashabaranov/go-openai"

"github.com/eryajf/chatgpt-dingtalk/config"
"github.com/eryajf/chatgpt-dingtalk/pkg/cache"
"github.com/eryajf/chatgpt-dingtalk/pkg/db"
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
"github.com/sashabaranov/go-openai"
)

var UserService cache.UserServiceInterface
Expand Down
3 changes: 2 additions & 1 deletion public/tools_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package public

import (
"github.com/eryajf/chatgpt-dingtalk/config"
"testing"

"github.com/eryajf/chatgpt-dingtalk/config"
)

func TestCheckRequestWithCredentials_Pass_WithNilConfig(t *testing.T) {
Expand Down
11 changes: 11 additions & 0 deletions scripts/goimports-reviser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

go install github.com/incu6us/goimports-reviser/v2@latest

PROJECT_NAME=github.com/eryajf/chatgpt-dingtalk

find . -name '*.go' -print0 | while IFS= read -r -d '' file; do
goimports-reviser -file-path "$file" -project-name "$PROJECT_NAME"
done

0 comments on commit f397318

Please sign in to comment.