mirror of
https://github.com/eryajf/chatgpt-dingtalk.git
synced 2025-09-27 04:36:08 +08:00
feat: makefile support go sort imports (#282)
This commit is contained in:
5
Makefile
5
Makefile
@@ -13,4 +13,7 @@ build-linux-arm:
|
|||||||
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -o chatgpt-dingtalk main.go
|
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -o chatgpt-dingtalk main.go
|
||||||
|
|
||||||
lint:
|
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
|
||||||
|
@@ -10,8 +10,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Credential struct {
|
type Credential struct {
|
||||||
|
7
main.go
7
main.go
@@ -9,13 +9,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"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/dingbot"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/process"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/process"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/public"
|
"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() {
|
func init() {
|
||||||
|
3
pkg/cache/user_base.go
vendored
3
pkg/cache/user_base.go
vendored
@@ -3,8 +3,9 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/config"
|
|
||||||
"github.com/patrickmn/go-cache"
|
"github.com/patrickmn/go-cache"
|
||||||
|
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserServiceInterface 用户业务接口
|
// UserServiceInterface 用户业务接口
|
||||||
|
@@ -6,8 +6,9 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/public"
|
|
||||||
openai "github.com/sashabaranov/go-openai"
|
openai "github.com/sashabaranov/go-openai"
|
||||||
|
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/public"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ChatGPT struct {
|
type ChatGPT struct {
|
||||||
|
@@ -12,11 +12,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
|
|
||||||
"github.com/pandodao/tokenizer-go"
|
"github.com/pandodao/tokenizer-go"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/public"
|
|
||||||
openai "github.com/sashabaranov/go-openai"
|
openai "github.com/sashabaranov/go-openai"
|
||||||
|
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/public"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/avast/retry-go"
|
"github.com/avast/retry-go"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/public"
|
"github.com/eryajf/chatgpt-dingtalk/public"
|
||||||
)
|
)
|
||||||
|
@@ -3,9 +3,10 @@ package db
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
|
||||||
"github.com/glebarez/sqlite"
|
"github.com/glebarez/sqlite"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 全局数据库对象
|
// 全局数据库对象
|
||||||
|
@@ -5,13 +5,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/config"
|
|
||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
url2 "net/url"
|
url2 "net/url"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OpenAPI doc: https://open.dingtalk.com/document/isvapp/upload-media-files
|
// OpenAPI doc: https://open.dingtalk.com/document/isvapp/upload-media-files
|
||||||
|
@@ -2,12 +2,13 @@ package dingbot
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/config"
|
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/png"
|
"image/png"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUploadMedia_Pass_WithValidConfig(t *testing.T) {
|
func TestUploadMedia_Pass_WithValidConfig(t *testing.T) {
|
||||||
|
@@ -3,13 +3,14 @@ package process
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/public"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/solywsh/chatgpt"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/db"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/db"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
||||||
"github.com/solywsh/chatgpt"
|
"github.com/eryajf/chatgpt-dingtalk/public"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImageGenerate openai生成图片
|
// ImageGenerate openai生成图片
|
||||||
|
@@ -6,11 +6,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/solywsh/chatgpt"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/db"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/db"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/logger"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/public"
|
"github.com/eryajf/chatgpt-dingtalk/public"
|
||||||
"github.com/solywsh/chatgpt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProcessRequest 分析处理请求逻辑
|
// ProcessRequest 分析处理请求逻辑
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
package public
|
package public
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/sashabaranov/go-openai"
|
||||||
|
|
||||||
"github.com/eryajf/chatgpt-dingtalk/config"
|
"github.com/eryajf/chatgpt-dingtalk/config"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/cache"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/cache"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/db"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/db"
|
||||||
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
|
"github.com/eryajf/chatgpt-dingtalk/pkg/dingbot"
|
||||||
"github.com/sashabaranov/go-openai"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var UserService cache.UserServiceInterface
|
var UserService cache.UserServiceInterface
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
package public
|
package public
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/eryajf/chatgpt-dingtalk/config"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/eryajf/chatgpt-dingtalk/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCheckRequestWithCredentials_Pass_WithNilConfig(t *testing.T) {
|
func TestCheckRequestWithCredentials_Pass_WithNilConfig(t *testing.T) {
|
||||||
|
11
scripts/goimports-reviser.sh
Executable file
11
scripts/goimports-reviser.sh
Executable file
@@ -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
|
Reference in New Issue
Block a user