Skip to content

Commit

Permalink
fixed golint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
or-shachar committed Nov 25, 2023
1 parent daa625f commit 8f9b04d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion cacheproc/cacheproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ import (
"github.com/bradfitz/go-tool-cache/wire"
)

type cacherCtxKey string

var (
ErrUnknownCommand = errors.New("unknown command")
ErrNoOutputID = errors.New("no outputID")
requestIDKey = cacherCtxKey("requestID")
)

// Process implements the cmd/go JSON protocol over stdin & stdout via three
Expand Down Expand Up @@ -68,6 +71,9 @@ func (p *Process) Run(ctx context.Context) error {
_ = p.close()
}()
for {
if err := ctx.Err(); err != nil {

}
var req wire.Request
if err := jd.Decode(&req); err != nil {
if errors.Is(err, io.EOF) {
Expand All @@ -89,7 +95,7 @@ func (p *Process) Run(ctx context.Context) error {
}
wg.Go(func() error {
res := &wire.Response{ID: req.ID}
ctx := context.WithValue(ctx, "requestID", &req)
ctx := context.WithValue(ctx, requestIDKey, &req)
if err := p.handleRequest(ctx, &req, res); err != nil {
res.Err = err.Error()
}
Expand All @@ -99,6 +105,11 @@ func (p *Process) Run(ctx context.Context) error {
_ = bw.Flush()
return nil
})
select {
case <-ctx.Done():
break
default:
}
}
return wg.Wait()
}
Expand Down
2 changes: 1 addition & 1 deletion cachers/counts.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type LocalCacheWithCounts struct {
}

func (l *LocalCacheWithCounts) Kind() string {
return l.Kind()
return l.cache.Kind()
}

type RemoteCacheWithCounts struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/go-cacher-server/cacher-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case strings.HasPrefix(r.URL.Path, "/output/"):
s.handleGetOutput(w, r)
case r.URL.Path == "/":
io.WriteString(w, "hi")
_, _ = io.WriteString(w, "hi")
default:
http.Error(w, "not found", http.StatusNotFound)
}
Expand Down Expand Up @@ -150,7 +150,7 @@ func (s *server) handleGetAction(w http.ResponseWriter, r *http.Request) {
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(&cachers.ActionValue{
_ = json.NewEncoder(w).Encode(&cachers.ActionValue{
OutputID: outputID,
Size: fi.Size(),
})
Expand Down

0 comments on commit 8f9b04d

Please sign in to comment.