diff --git a/antlr/GruleParserV3_test.go b/antlr/GruleParserV3_test.go index 154966b9..ca01fc3a 100755 --- a/antlr/GruleParserV3_test.go +++ b/antlr/GruleParserV3_test.go @@ -16,7 +16,7 @@ package antlr import ( "fmt" - "io/ioutil" + "os" "reflect" "testing" @@ -105,7 +105,7 @@ type GrandChild struct { } func TestV3Lexer(t *testing.T) { - data, err := ioutil.ReadFile("./sample4.grl") + data, err := os.ReadFile("./sample4.grl") if err != nil { t.Fatal(err) } else { @@ -129,7 +129,7 @@ func TestV3Lexer(t *testing.T) { func TestV3Parser(t *testing.T) { // logrus.SetLevel(logrus.TraceLevel) - data, err := ioutil.ReadFile("./sample4.grl") + data, err := os.ReadFile("./sample4.grl") if err != nil { t.Fatal(err) } else { diff --git a/editor/EvaluationRoute.go b/editor/EvaluationRoute.go index 2cdb30c9..66489f3d 100644 --- a/editor/EvaluationRoute.go +++ b/editor/EvaluationRoute.go @@ -9,7 +9,7 @@ import ( "github.com/hyperjumptech/grule-rule-engine/engine" "github.com/hyperjumptech/grule-rule-engine/pkg" mux "github.com/hyperjumptech/hyper-mux" - "io/ioutil" + "io" "net/http" ) @@ -25,7 +25,7 @@ type EvaluateRequest struct { func InitializeEvaluationRoute(router *mux.HyperMux) { router.AddRoute("/evaluate", http.MethodPost, func(writer http.ResponseWriter, reader *http.Request) { - bodyBytes, err := ioutil.ReadAll(reader.Body) + bodyBytes, err := io.ReadAll(reader.Body) if err != nil { writer.WriteHeader(http.StatusInternalServerError) _, _ = writer.Write([]byte(fmt.Sprintf("error while reading body stream. got %v", err))) diff --git a/examples/benchmark/ExecRules_benchmark_test.go b/examples/benchmark/ExecRules_benchmark_test.go index 092e584b..4c3ecd10 100644 --- a/examples/benchmark/ExecRules_benchmark_test.go +++ b/examples/benchmark/ExecRules_benchmark_test.go @@ -20,7 +20,7 @@ import ( "github.com/hyperjumptech/grule-rule-engine/builder" "github.com/hyperjumptech/grule-rule-engine/engine" "github.com/hyperjumptech/grule-rule-engine/pkg" - "io/ioutil" + "os" "testing" ) @@ -66,7 +66,7 @@ func Benchmark_Grule_Execution_Engine(b *testing.B) { } func load100RulesIntoKnowledgebase() { - input, _ := ioutil.ReadFile("100_rules.grl") + input, _ := os.ReadFile("100_rules.grl") rules := string(input) fact := &RideFact{ Distance: 6000, @@ -83,7 +83,7 @@ func load100RulesIntoKnowledgebase() { } func load1000RulesIntoKnowledgebase() { - input, _ := ioutil.ReadFile("1000_rules.grl") + input, _ := os.ReadFile("1000_rules.grl") rules := string(input) fact := &RideFact{ Distance: 6000, diff --git a/examples/benchmark/LoadRules_benchmark_test.go b/examples/benchmark/LoadRules_benchmark_test.go index 0d757a6d..748bb62a 100755 --- a/examples/benchmark/LoadRules_benchmark_test.go +++ b/examples/benchmark/LoadRules_benchmark_test.go @@ -19,7 +19,7 @@ import ( "github.com/hyperjumptech/grule-rule-engine/ast" "github.com/hyperjumptech/grule-rule-engine/builder" "github.com/hyperjumptech/grule-rule-engine/pkg" - "io/ioutil" + "os" "testing" ) @@ -58,7 +58,7 @@ func Benchmark_Grule_Load_Rules(b *testing.B) { } func load100RulesIntoKnowledgeBase() { - input, _ := ioutil.ReadFile("100_rules.grl") + input, _ := os.ReadFile("100_rules.grl") rules := string(input) fact := &RideFact{ Distance: 6000, @@ -74,7 +74,7 @@ func load100RulesIntoKnowledgeBase() { } func load1000RulesIntoKnowledgeBase() { - input, _ := ioutil.ReadFile("1000_rules.grl") + input, _ := os.ReadFile("1000_rules.grl") rules := string(input) fact := &RideFact{ Distance: 6000, diff --git a/pkg/resource.go b/pkg/resource.go index 9aba3704..a660f225 100644 --- a/pkg/resource.go +++ b/pkg/resource.go @@ -18,8 +18,8 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" + "os" "path/filepath" "time" @@ -59,7 +59,7 @@ type ReaderResource struct { // Load will load the resource into byte array. func (res *ReaderResource) Load() ([]byte, error) { - return ioutil.ReadAll(res.Reader) + return io.ReadAll(res.Reader) } // String will state the resource source. @@ -124,7 +124,7 @@ func (bundle *FileResourceBundle) MustLoad() []Resource { func (bundle *FileResourceBundle) loadPath(path string) ([]Resource, error) { logger.Log.Tracef("Enter directory %s", path) - finfos, err := ioutil.ReadDir(path) + finfos, err := os.ReadDir(path) if err != nil { @@ -148,7 +148,7 @@ func (bundle *FileResourceBundle) loadPath(path string) ([]Resource, error) { } if matched { logger.Log.Debugf("Loading file %s", fulPath) - bytes, err := ioutil.ReadFile(fulPath) + bytes, err := os.ReadFile(fulPath) if err != nil { return nil, err } @@ -182,7 +182,7 @@ func (res *FileResource) Load() ([]byte, error) { return res.Bytes, nil } - data, err := ioutil.ReadFile(res.Path) + data, err := os.ReadFile(res.Path) if err != nil { return nil, err @@ -280,7 +280,7 @@ func (res *URLResource) Load() ([]byte, error) { return nil, err } defer resp.Body.Close() - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return nil, err @@ -360,7 +360,7 @@ func (bundle *GITResourceBundle) loadPath(url, path string, fileSyst billy.Files return nil, err } - bytes, err := ioutil.ReadAll(f) + bytes, err := io.ReadAll(f) if err != nil { return nil, err