Skip to content

Commit

Permalink
fix(lint): fix failing lints, add Docker command to Makefile, closes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
camerondurham committed Feb 1, 2022
1 parent ba5c748 commit da4be57
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ all:
@echo ""
@echo " fmt: run go fmt on the repository"
@echo ""
@echo " lint: run Docker golang-lint-ci for the repository"
@echo ""
@echo " install-hooks: install git-hooks in the cloned repo .git directory"
@echo ""

Expand All @@ -40,6 +42,9 @@ test:
fmt:
go fmt ./...

lint:
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.44.0 golangci-lint run ./... -v

install-hooks:
@echo "installing git hooks"
cp ./hack/hooks/* .git/hooks/
Expand Down
11 changes: 9 additions & 2 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"

Expand All @@ -24,7 +25,10 @@ func languagesHandler(w http.ResponseWriter, r *http.Request) {
langs := LanguagesResponse{
Languages: coderunner.Languages,
}
json.NewEncoder(w).Encode(langs)
err := json.NewEncoder(w).Encode(langs)
if err != nil {
log.Printf("failed to encode languages reponse: %v", err)
}
}

type RunResponse struct {
Expand All @@ -45,7 +49,10 @@ func runHandler(w http.ResponseWriter, r *http.Request) {
Stderr: "",
}

json.NewEncoder(w).Encode(output)
err := json.NewEncoder(w).Encode(output)
if err != nil {
log.Printf("failed to encode run output: %v\n", err)
}
}

func main() {
Expand Down
5 changes: 0 additions & 5 deletions engine/coderunner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import (
)

func TestCodeRunner_Run(t *testing.T) {
type fields struct {
runner runtime.Runtime
workdirPath string
}

type args struct {
props *RunnerProps
}
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ make test
# run go fmt on the repository to format your code
make fmt

# run the golang-lint-ci on the package to find common mistakes or unused data structures
make lint

# install git-hooks to automatically format your code before you commit
make install-hooks
```
Expand Down

0 comments on commit da4be57

Please sign in to comment.