Skip to content

Commit 98028de

Browse files
committed
feat: add go releaser
1 parent 61780ee commit 98028de

6 files changed

Lines changed: 60 additions & 17 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ conf/
2323
db/
2424
tmp/
2525
easeway.tar
26+
27+
dist/

.goreleaser.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
4+
# The lines below are called `modelines`. See `:help modeline`
5+
# Feel free to remove those if you don't want/need to use them.
6+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
8+
9+
version: 2
10+
11+
before:
12+
hooks:
13+
# You may remove this if you don't use go modules.
14+
- go mod tidy
15+
# you may remove this if you don't need go generate
16+
- go generate ./...
17+
18+
builds:
19+
- env:
20+
- CGO_ENABLED=0
21+
main: ./cmd/
22+
goos:
23+
- linux
24+
- windows
25+
- darwin
26+
27+
archives:
28+
- format: tar.gz
29+
# this name template makes the OS and Arch compatible with the results of `uname`.
30+
name_template: >-
31+
{{ .ProjectName }}_
32+
{{- title .Os }}_
33+
{{- if eq .Arch "amd64" }}x86_64
34+
{{- else if eq .Arch "386" }}i386
35+
{{- else }}{{ .Arch }}{{ end }}
36+
{{- if .Arm }}v{{ .Arm }}{{ end }}
37+
# use zip for windows archives
38+
format_overrides:
39+
- goos: windows
40+
format: zip
41+
42+
changelog:
43+
sort: asc
44+
filters:
45+
exclude:
46+
- "^docs:"
47+
- "^test:"
48+
49+
release:
50+
footer: >-
51+
52+
---
53+
54+
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).

Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
FROM golang:1.22 AS build-stage
22

33
WORKDIR /build
4-
54
ENV GOPROXY https://goproxy.cn,direct
6-
75
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
86
COPY go.mod go.sum ./
97
RUN go mod download && go mod verify
10-
118
COPY . .
129
RUN go build -v -o /build/easeway ./cmd
1310

14-
FROM debian:12 AS build-release-stage
15-
16-
RUN apt-get update && apt-get install -y ca-certificates
11+
FROM scratch
1712
WORKDIR /app
1813
COPY --from=build-stage /build/easeway easeway
1914
EXPOSE 8055

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ go 1.22.2
44

55
require (
66
github.com/a-h/templ v0.2.680
7+
github.com/gage-technologies/mistral-go v1.0.1
78
github.com/google/generative-ai-go v0.11.2
89
github.com/google/uuid v1.6.0
910
github.com/jackc/pgx/v5 v5.5.5
1011
github.com/labstack/echo/v4 v4.12.0
12+
github.com/liushuangls/go-anthropic/v2 v2.6.0
1113
github.com/pkoukk/tiktoken-go v0.1.6
1214
github.com/pkoukk/tiktoken-go-loader v0.0.1
1315
github.com/sashabaranov/go-openai v1.24.0
1416
google.golang.org/api v0.176.1
15-
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
1617
gopkg.in/yaml.v2 v2.4.0
1718
)
1819

@@ -25,7 +26,6 @@ require (
2526
cloud.google.com/go/longrunning v0.5.6 // indirect
2627
github.com/dlclark/regexp2 v1.10.0 // indirect
2728
github.com/felixge/httpsnoop v1.0.4 // indirect
28-
github.com/gage-technologies/mistral-go v1.0.1 // indirect
2929
github.com/go-logr/logr v1.4.1 // indirect
3030
github.com/go-logr/stdr v1.2.2 // indirect
3131
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
@@ -39,7 +39,6 @@ require (
3939
github.com/jackc/puddle/v2 v2.2.1 // indirect
4040
github.com/kr/text v0.2.0 // indirect
4141
github.com/labstack/gommon v0.4.2 // indirect
42-
github.com/liushuangls/go-anthropic/v2 v2.6.0 // indirect
4342
github.com/mattn/go-colorable v0.1.13 // indirect
4443
github.com/mattn/go-isatty v0.0.20 // indirect
4544
github.com/rogpeppe/go-internal v1.12.0 // indirect
@@ -62,5 +61,4 @@ require (
6261
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
6362
google.golang.org/grpc v1.63.2 // indirect
6463
google.golang.org/protobuf v1.33.0 // indirect
65-
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
6664
)

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
105105
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
106106
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
107107
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
108-
github.com/sashabaranov/go-openai v1.21.0 h1:isAf3zPSD3VLd0pC2/2Q6ZyRK7jzPAaz+X3rjsviaYQ=
109-
github.com/sashabaranov/go-openai v1.21.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
110108
github.com/sashabaranov/go-openai v1.24.0 h1:4H4Pg8Bl2RH/YSnU8DYumZbuHnnkfioor/dtNlB20D4=
111109
github.com/sashabaranov/go-openai v1.24.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
112110
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -208,13 +206,9 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
208206
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
209207
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
210208
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
211-
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
212-
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
213209
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
214210
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
215211
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
216-
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
217-
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
218212
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
219213
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
220214
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/handlers/anthropic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (a *AnthropicApiHandler) CreateMessages(c echo.Context) error {
6868
if err != nil {
6969
var e *anthropic.APIError
7070
if errors.As(err, &e) {
71-
slog.Error("Messages stream error, type: %s, message: %s", e.Type, e.Message)
71+
slog.Error("Messages stream error, type: %s, message: %s", string(e.Type), e.Message)
7272
} else {
7373
slog.Error("do chat completion error", slog.Any("error", err))
7474
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())

0 commit comments

Comments
 (0)