Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tour_of_beam_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ jobs:
run: go test -v ./...

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v9
with:
version: v1.49.0
version: v2.12.2
working-directory: learning/tour-of-beam/backend

6 changes: 3 additions & 3 deletions learning/tour-of-beam/backend/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func postUnitComplete(w http.ResponseWriter, r *http.Request) {
return
}

fmt.Fprint(w, "{}")
_, _ = fmt.Fprint(w, "{}")
}

// Save user code for unit
Expand Down Expand Up @@ -245,7 +245,7 @@ func postUserCode(w http.ResponseWriter, r *http.Request) {
return
}

fmt.Fprint(w, "{}")
_, _ = fmt.Fprint(w, "{}")
}

// Delete user progress
Expand All @@ -259,5 +259,5 @@ func postDeleteProgress(w http.ResponseWriter, r *http.Request) {
return
}

fmt.Fprint(w, "{}")
_, _ = fmt.Fprint(w, "{}")
}
8 changes: 6 additions & 2 deletions learning/tour-of-beam/backend/integration_tests/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ func Do(dst interface{}, method, url string, queryParams, headers map[string]str
if err != nil {
return err
}
defer resp.Body.Close()
defer func() {
_ = resp.Body.Close()
}()

if err := verifyServerHeaders(resp.Header); err != nil {
return err
Expand All @@ -180,7 +182,9 @@ func Do(dst interface{}, method, url string, queryParams, headers map[string]str
}

tee := io.TeeReader(resp.Body, os.Stdout)
defer os.Stdout.WriteString("\n")
defer func() {
_, _ = os.Stdout.WriteString("\n")
}()
if err := json.NewDecoder(tee).Decode(dst); err != nil {
return fmt.Errorf("response decode err: %w", err)
}
Expand Down
10 changes: 5 additions & 5 deletions learning/tour-of-beam/backend/internal/fs_content/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
package fs_content

import (
"io/ioutil"
"log"
"os"

"gopkg.in/yaml.v3"
)

// Could have done it in generics if 1.18 was supported in GCF
// Fatals on error.
func loadLearningPathInfo(path string) (info learningPathInfo) {
buf, err := ioutil.ReadFile(path)
buf, err := os.ReadFile(path)
if err != nil {
log.Fatal(err)
}
Expand All @@ -39,7 +39,7 @@ func loadLearningPathInfo(path string) (info learningPathInfo) {
}

func loadLearningModuleInfo(path string) (info learningModuleInfo) {
buf, err := ioutil.ReadFile(path)
buf, err := os.ReadFile(path)
if err != nil {
log.Fatal(err)
}
Expand All @@ -53,7 +53,7 @@ func loadLearningModuleInfo(path string) (info learningModuleInfo) {
}

func loadLearningGroupInfo(path string) (info learningGroupInfo) {
buf, err := ioutil.ReadFile(path)
buf, err := os.ReadFile(path)
if err != nil {
log.Fatal(err)
}
Expand All @@ -67,7 +67,7 @@ func loadLearningGroupInfo(path string) (info learningGroupInfo) {
}

func loadLearningUnitInfo(path string) (info learningUnitInfo) {
buf, err := ioutil.ReadFile(path)
buf, err := os.ReadFile(path)
if err != nil {
log.Fatal(err)
}
Expand Down
11 changes: 6 additions & 5 deletions learning/tour-of-beam/backend/internal/storage/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (d *DatastoreDb) saveContentTree(tx *datastore.Transaction, tree *tob.Conte
// could have used numericID keys, if there was no transaction:
// incomplete keys are resolved after Tx commit, and
// we need to reference them in child nodes
var groupId int = 0
groupId := 0
genGroupKey := func(parentKey *datastore.Key) *datastore.Key {
groupId++
return datastoreKey(TbLearningNodeKind,
Expand All @@ -181,13 +181,14 @@ func (d *DatastoreDb) saveContentTree(tx *datastore.Transaction, tree *tob.Conte
}

saveNode = func(node tob.Node, order, level int, parentKey *datastore.Key) error {
if node.Type == tob.NODE_UNIT {
switch node.Type {
case tob.NODE_UNIT:
return saveUnit(node.Unit, order, level, parentKey)
} else if node.Type == tob.NODE_GROUP {
case tob.NODE_GROUP:
return saveGroup(node.Group, order, level, parentKey)
default:
return fmt.Errorf("unknown datastore node type: %v", node.Type)
}

return fmt.Errorf("unknown datastore node type: %v", node.Type)
}

rootKey := pgNameKey(TbLearningPathKind, tree.Sdk.StorageID(), nil)
Expand Down
8 changes: 4 additions & 4 deletions learning/tour-of-beam/backend/internal/storage/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"context"
"encoding/json"
"errors"
"io/ioutil"
"os"
"path"
"runtime"
"strings"
Expand All @@ -42,7 +42,7 @@ func (d *Mock) GetContentTree(_ context.Context, sdk tob.Sdk) (ct tob.ContentTre
if sdk == tob.SDK_SCIO {
return ct, errors.New("empty sdk tree")
}
content, _ := ioutil.ReadFile(path.Join(getSamplesPath(), "get_content_tree.json"))
content, _ := os.ReadFile(path.Join(getSamplesPath(), "get_content_tree.json"))
_ = json.Unmarshal(content, &ct)
return ct, nil
}
Expand All @@ -55,7 +55,7 @@ func (d *Mock) GetUnitContent(_ context.Context, sdk tob.Sdk, unitId string) (u
if strings.HasPrefix(unitId, "unknown_") {
return u, tob.ErrNoUnit
}
content, _ := ioutil.ReadFile(path.Join(getSamplesPath(), "get_unit_content.json"))
content, _ := os.ReadFile(path.Join(getSamplesPath(), "get_unit_content.json"))
err = json.Unmarshal(content, &u)
return u, err
}
Expand All @@ -74,7 +74,7 @@ func (d *Mock) SaveUser(ctx context.Context, uid string) error {
}

func (d *Mock) GetUserProgress(_ context.Context, sdk tob.Sdk, userId string) (sp *tob.SdkProgress, err error) {
content, _ := ioutil.ReadFile(path.Join(getSamplesPath(), "get_user_progress.json"))
content, _ := os.ReadFile(path.Join(getSamplesPath(), "get_user_progress.json"))
_ = json.Unmarshal(content, &sp)
return sp, nil
}
Expand Down
Loading