Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SXMC-198): Fix goflow compiler error #44

Merged
merged 4 commits into from
May 10, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.47.2
version: v1.58.0
- name: Check diffs
# --name-only first for debugging
run: git diff --name-only && git diff --quiet
4 changes: 2 additions & 2 deletions checkers/unused/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func (e Error) Error() string {
}

// Check checks that all nodes are used in one way or another:
// - have only one error output
// - are used explicitly
// - have only one error output
// - are used explicitly
func Check(graph goflow.GraphRenderer) error {
nodes := graph.Nodes()

Expand Down
7 changes: 3 additions & 4 deletions example/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"sort"
Expand Down Expand Up @@ -111,7 +110,7 @@ func main() {
continue
}

if err := ioutil.WriteFile(generatedFilename, buf.Bytes(), 0o600); err != nil {
if err := os.WriteFile(generatedFilename, buf.Bytes(), 0o600); err != nil {
genErrs = append(genErrs, err)
}

Expand All @@ -131,7 +130,7 @@ func main() {
return n1 <= n2
})
handleErr(json.NewEncoder(&buf).Encode(nodes))
handleErr(ioutil.WriteFile("nodes.json", buf.Bytes(), 0o600))
handleErr(os.WriteFile("nodes.json", buf.Bytes(), 0o600))

var graphLoader gfgo.NodeLoader
err = graphLoader.Load(
Expand All @@ -153,7 +152,7 @@ func main() {
err = goWriter.Flush()
handleErr(err)

err = ioutil.WriteFile(pgFilename, buf.Bytes(), 0o600)
err = os.WriteFile(pgFilename, buf.Bytes(), 0o600)
handleErr(err)
}

Expand Down
4 changes: 2 additions & 2 deletions gfutil/find.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package gfutil

import (
"io/ioutil"
"os"
"path"
"strings"
)

func FindGraphFileNames(dir string) ([]string, error) {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion gfutil/gfgo/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ func getDocFromPackage(pkg *packages.Package, pos token.Pos) string {

// parseTypesDoc hacks the thing by grabbing info of types using doc.
// TODO: review all this and improve if possible...
// shall we try with https://pkg.go.dev/go/ast?tab=doc#CommentGroup maybe?
//
// shall we try with https://pkg.go.dev/go/ast?tab=doc#CommentGroup maybe?
func parseTypesDoc(pkg *packages.Package) (map[string]string, error) {
if len(pkg.GoFiles) == 0 {
return nil, nil
Expand Down
5 changes: 2 additions & 3 deletions gfutil/gfgo/testutil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package goflow

import (
"fmt"
"io/ioutil"
"os"
"path"
"strings"
Expand All @@ -15,7 +14,7 @@ import (
//
// It also logs the time taken since start, because why not.
func WriteFile(content, filename string, start time.Time) error {
before, err := ioutil.ReadFile(filename)
before, err := os.ReadFile(filename)
if err != nil && !os.IsNotExist(err) {
return err
}
Expand Down Expand Up @@ -46,7 +45,7 @@ func WriteFile(content, filename string, start time.Time) error {
}

func FindGraphFileNames(dir string) ([]string, error) {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package goflow
// - NodeWrapper
// - Linter
// - Checker
//
// goflow provides functions to use those simpler types as GraphWrappers.
type GraphWrapper func(unmarshal func(interface{}) error, graph GraphRenderer) (GraphRenderer, error)

Expand Down
2 changes: 0 additions & 2 deletions wrappers/bind/graph/bind.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions wrappers/constants/graph/constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions wrappers/ctx/graph/ctx.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions wrappers/gonodes/graph/gonodes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions wrappers/ifs/graph/ifs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 45 additions & 2 deletions wrappers/mockingjay/graph/mockingjay.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions wrappers/mockingjay/mockingjay.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func WithMock(ctx context.Context, nodeID string, values ...interface{}) context
//
// The WithMock helper function is provided to make it easier to mock node:
//
// ctx := mockingjay.WithMock(ctx, "myNode", 42)
// graph.Run(ctx, ...)
// ctx := mockingjay.WithMock(ctx, "myNode", 42)
// graph.Run(ctx, ...)
func Mock(_ func(interface{}) error, node goflow.NodeRenderer) (goflow.NodeRenderer, error) {
return mocker{
NodeRenderer: ctx.Injector{
Expand Down
7 changes: 7 additions & 0 deletions wrappers/mockingjay/mockingjay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@ nodes:
a: inputs.a
b: inputs.b

- id: print
type: nodes.PrinterCtx
bind:
values:
- '"sum"'
- add.sum

outputs:
sum: add.sum
2 changes: 0 additions & 2 deletions wrappers/outputs/graph/outputs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading