This is an automated email from the ASF dual-hosted git repository.
derrickaw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 3926b886590 fix golangci-lint issue - tour of beam (#39490)
3926b886590 is described below
commit 3926b88659041af41ab38fca750f81bb656169b6
Author: Derrick Williams <[email protected]>
AuthorDate: Tue Jul 28 20:02:56 2026 -0400
fix golangci-lint issue - tour of beam (#39490)
* fix golangci-lint issue
* fix golang action version
* one more version change
* fix golint formatting issues
* more lint issues - getting closer
* fix fmt issue
---
.github/workflows/tour_of_beam_backend.yml | 4 ++--
learning/tour-of-beam/backend/function.go | 6 +++---
learning/tour-of-beam/backend/integration_tests/client.go | 8 ++++++--
learning/tour-of-beam/backend/internal/fs_content/yaml.go | 10 +++++-----
learning/tour-of-beam/backend/internal/storage/datastore.go | 11 ++++++-----
learning/tour-of-beam/backend/internal/storage/mock.go | 8 ++++----
6 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/tour_of_beam_backend.yml
b/.github/workflows/tour_of_beam_backend.yml
index f93edc0fd62..1c7c3c079d5 100644
--- a/.github/workflows/tour_of_beam_backend.yml
+++ b/.github/workflows/tour_of_beam_backend.yml
@@ -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
diff --git a/learning/tour-of-beam/backend/function.go
b/learning/tour-of-beam/backend/function.go
index 90ed8642580..eaa1dcad076 100644
--- a/learning/tour-of-beam/backend/function.go
+++ b/learning/tour-of-beam/backend/function.go
@@ -213,7 +213,7 @@ func postUnitComplete(w http.ResponseWriter, r
*http.Request) {
return
}
- fmt.Fprint(w, "{}")
+ _, _ = fmt.Fprint(w, "{}")
}
// Save user code for unit
@@ -245,7 +245,7 @@ func postUserCode(w http.ResponseWriter, r *http.Request) {
return
}
- fmt.Fprint(w, "{}")
+ _, _ = fmt.Fprint(w, "{}")
}
// Delete user progress
@@ -259,5 +259,5 @@ func postDeleteProgress(w http.ResponseWriter, r
*http.Request) {
return
}
- fmt.Fprint(w, "{}")
+ _, _ = fmt.Fprint(w, "{}")
}
diff --git a/learning/tour-of-beam/backend/integration_tests/client.go
b/learning/tour-of-beam/backend/integration_tests/client.go
index 956c67dde5d..9b169f08536 100644
--- a/learning/tour-of-beam/backend/integration_tests/client.go
+++ b/learning/tour-of-beam/backend/integration_tests/client.go
@@ -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
@@ -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)
}
diff --git a/learning/tour-of-beam/backend/internal/fs_content/yaml.go
b/learning/tour-of-beam/backend/internal/fs_content/yaml.go
index 0546637a0d5..ebb8d97e11f 100644
--- a/learning/tour-of-beam/backend/internal/fs_content/yaml.go
+++ b/learning/tour-of-beam/backend/internal/fs_content/yaml.go
@@ -16,8 +16,8 @@
package fs_content
import (
- "io/ioutil"
"log"
+ "os"
"gopkg.in/yaml.v3"
)
@@ -25,7 +25,7 @@ import (
// 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)
}
@@ -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)
}
@@ -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)
}
@@ -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)
}
diff --git a/learning/tour-of-beam/backend/internal/storage/datastore.go
b/learning/tour-of-beam/backend/internal/storage/datastore.go
index 4c95384a9a0..cdf63321161 100644
--- a/learning/tour-of-beam/backend/internal/storage/datastore.go
+++ b/learning/tour-of-beam/backend/internal/storage/datastore.go
@@ -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,
@@ -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)
diff --git a/learning/tour-of-beam/backend/internal/storage/mock.go
b/learning/tour-of-beam/backend/internal/storage/mock.go
index 2a39c774bd2..3a28ef979c1 100644
--- a/learning/tour-of-beam/backend/internal/storage/mock.go
+++ b/learning/tour-of-beam/backend/internal/storage/mock.go
@@ -19,7 +19,7 @@ import (
"context"
"encoding/json"
"errors"
- "io/ioutil"
+ "os"
"path"
"runtime"
"strings"
@@ -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
}
@@ -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
}
@@ -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
}