Skip to content

Commit

Permalink
add .golangci.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyng committed Jan 9, 2024
1 parent 9972531 commit acfc376
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
27 changes: 27 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
run:
timeout: 5m
linters:
enable:
- asasalint
- bidichk
- bodyclose
- containedctx
- contextcheck
- exportloopref
- gocheckcompilerdirectives
# FIXME: for some reason this errors on windows
# - gofmt
# - goimports
- misspell
- nilerr
- unused
linters-settings:
errcheck:
# exclude the following functions since we don't generally
# need to be concerned with the returned errors
exclude-functions:
- encoding/binary.Read
- (*os.File).Seek
- (*bufio.Writer).WriteString
- (*github.com/spf13/pflag.FlagSet).Set
- (*github.com/jmorganca/ollama/llm.readSeekOffset).Seek
4 changes: 2 additions & 2 deletions readline/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (h *History) Init() error {

h.Filename = path

f, err := os.OpenFile(path, os.O_CREATE|os.O_RDONLY, 0600)
f, err := os.OpenFile(path, os.O_CREATE|os.O_RDONLY, 0o600)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil
Expand Down Expand Up @@ -132,7 +132,7 @@ func (h *History) Save() error {

tmpFile := h.Filename + ".tmp"

f, err := os.OpenFile(tmpFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC|os.O_APPEND, 0666)
f, err := os.OpenFile(tmpFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC|os.O_APPEND, 0o666)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions server/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (b *blobDownload) Prepare(ctx context.Context, requestURL *url.URL, opts *R

b.Total, _ = strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64)

var size = b.Total / numDownloadParts
size := b.Total / numDownloadParts
switch {
case size < minDownloadPartSize:
size = minDownloadPartSize
Expand Down Expand Up @@ -132,7 +132,7 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *Regis
defer blobDownloadManager.Delete(b.Digest)
ctx, b.CancelFunc = context.WithCancel(ctx)

file, err := os.OpenFile(b.Name+"-partial", os.O_CREATE|os.O_RDWR, 0644)
file, err := os.OpenFile(b.Name+"-partial", os.O_CREATE|os.O_RDWR, 0o644)
if err != nil {
return err
}
Expand Down Expand Up @@ -246,7 +246,7 @@ func (b *blobDownload) readPart(partName string) (*blobDownloadPart, error) {
}

func (b *blobDownload) writePart(partName string, part *blobDownloadPart) error {
partFile, err := os.OpenFile(partName, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
partFile, err := os.OpenFile(partName, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o644)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions server/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func WriteManifest(name string, config *Layer, layers []*Layer) error {
return err
}

if err := os.MkdirAll(filepath.Dir(manifestPath), 0755); err != nil {
if err := os.MkdirAll(filepath.Dir(manifestPath), 0o755); err != nil {
return err
}

return os.WriteFile(manifestPath, b.Bytes(), 0644)
return os.WriteFile(manifestPath, b.Bytes(), 0o644)
}
3 changes: 2 additions & 1 deletion server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ func GenerateHandler(c *gin.Context) {
c.JSON(http.StatusOK, api.GenerateResponse{
CreatedAt: time.Now().UTC(),
Model: req.Model,
Done: true})
Done: true,
})
return
}

Expand Down
1 change: 0 additions & 1 deletion server/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,4 @@ func Test_Routes(t *testing.T) {
}

}

}
2 changes: 1 addition & 1 deletion server/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (b *blobUpload) Prepare(ctx context.Context, requestURL *url.URL, opts *Reg
return nil
}

var size = b.Total / numUploadParts
size := b.Total / numUploadParts
switch {
case size < minUploadPartSize:
size = minUploadPartSize
Expand Down

0 comments on commit acfc376

Please sign in to comment.