Init GoReleaser (#27)

This commit is contained in:
sunboyy 2021-11-27 12:20:30 +07:00 committed by GitHub
parent 8081ffcb0f
commit 440b92a742
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

3
.gitignore vendored
View file

@ -1,2 +1,5 @@
*.out *.out
cover* cover*
# goreleaser builds
dist/

23
.goreleaser.yml Normal file
View file

@ -0,0 +1,23 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod tidy
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
- "386"
archives:
- replacements:
386: i386
amd64: x86_64
snapshot:
name_template: "{{ .Tag }}-next"

View file

@ -7,6 +7,7 @@ import (
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
) )
func NewUserRepository(collection *mongo.Collection) UserRepository { func NewUserRepository(collection *mongo.Collection) UserRepository {
@ -31,7 +32,7 @@ func (r *UserRepositoryMongo) FindByUsername(arg0 context.Context, arg1 string)
var entity UserModel var entity UserModel
if err := r.collection.FindOne(arg0, bson.M{ if err := r.collection.FindOne(arg0, bson.M{
"username": arg1, "username": arg1,
}).Decode(&entity); err != nil { }, options.FindOne().SetSort(bson.M{})).Decode(&entity); err != nil {
return nil, err return nil, err
} }
return &entity, nil return &entity, nil