diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 254d8e0..3327ebe 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,12 +19,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: '1.22' + go-version: '1.20.14' - uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 - args: --timeout=5m + version: v1.55.2 + args: --timeout=5m -v - name: Test run: make test diff --git a/.golangci.yml b/.golangci.yml index 487f960..2a3f2db 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,7 @@ # This code is licensed under the terms of the MIT license https://opensource.org/license/mit # Copyright (c) 2021 Marat Reymers -## Golden config for golangci-lint v1.61.0 +## Golden config for golangci-lint v1.55.2 # # This is the best config for golangci-lint based on my experience and opinion. # It is very strict, but not extremely strict. @@ -11,6 +11,9 @@ run: # Timeout for analysis, e.g. 30s, 5m. # Default: 1m timeout: 3m + tests: false + skip-dirs: + - rdt # skip generated code # This file contains only configs which differ from defaults. @@ -39,8 +42,7 @@ linters-settings: - map exhaustruct: - # List of regular expressions to exclude struct packages and their names from checks. - # Regular expressions must match complete canonical struct package/name/structname. + # List of regular expressions to exclude struct packages and names from check. # Default: [] exclude: # std libs @@ -99,6 +101,25 @@ linters-settings: # Default: true skipRecvDeref: false + gomnd: + # List of function patterns to exclude from analysis. + # Values always ignored: `time.Date`, + # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, + # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. + # Default: [] + ignored-functions: + - flag.Arg + - flag.Duration.* + - flag.Float.* + - flag.Int.* + - flag.Uint.* + - os.Chmod + - os.Mkdir.* + - os.OpenFile + - os.WriteFile + - prometheus.ExponentialBuckets.* + - prometheus.LinearBuckets + gomodguard: blocked: # List of blocked modules. @@ -114,8 +135,8 @@ linters-settings: reason: "satori's package is not maintained" - github.com/gofrs/uuid: recommendations: - - github.com/gofrs/uuid/v5 - reason: "gofrs' package was not go module before v5" + - github.com/google/uuid + reason: "gofrs' package is not go module" govet: # Enable all analyzers. @@ -133,31 +154,6 @@ linters-settings: # Default: false strict: true - inamedparam: - # Skips check for interface methods with only a single parameter. - # Default: false - skip-single-param: true - - mnd: - # List of function patterns to exclude from analysis. - # Values always ignored: `time.Date`, - # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, - # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. - # Default: [] - ignored-functions: - - args.Error - - flag.Arg - - flag.Duration.* - - flag.Float.* - - flag.Int.* - - flag.Uint.* - - os.Chmod - - os.Mkdir.* - - os.OpenFile - - os.WriteFile - - prometheus.ExponentialBuckets.* - - prometheus.LinearBuckets - nakedret: # Make an issue if func has more lines of code than this setting, and it has naked returns. # Default: 30 @@ -174,36 +170,12 @@ linters-settings: # Default: false require-specific: true - perfsprint: - # Optimizes into strings concatenation. - # Default: true - strconcat: false - errorf: false - rowserrcheck: # database/sql is always checked # Default: [] packages: - github.com/jmoiron/sqlx - sloglint: - # Enforce not using global loggers. - # Values: - # - "": disabled - # - "all": report all global loggers - # - "default": report only the default slog logger - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global - # Default: "" - #no-global: "all" - # Enforce using methods that accept a context. - # Values: - # - "": disabled - # - "all": report all contextless calls - # - "scope": report only if a context exists in the scope of the outermost function - # https://github.com/go-simpler/sloglint?tab=readme-ov-file#context-only - # Default: "" - context: "scope" - tenv: # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. @@ -219,46 +191,49 @@ linters: - govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string - ineffassign # detects when assignments to existing variables are not used - staticcheck # is a go vet on steroids, applying a ton of static analysis checks - - typecheck # like the front-end of a Go compiler, parses and type-checks Go code + #- typecheck # like the front-end of a Go compiler, parses and type-checks Go code - unused # checks for unused constants, variables, functions and types ## disabled by default - asasalint # checks for pass []any as any in variadic func(...any) - asciicheck # checks that your code does not contain non-ASCII identifiers - bidichk # checks for dangerous unicode character sequences - bodyclose # checks whether HTTP response body is closed successfully - - canonicalheader # checks whether net/http.Header uses canonical header - - copyloopvar # detects places where loop variables are copied (Go 1.22+) - cyclop # checks function and package cyclomatic complexity - dupl # tool for code clone detection - durationcheck # checks for two durations multiplied together - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 + - execinquery # checks query string in Query function which reads your Go src files and warning it finds - exhaustive # checks exhaustiveness of enum switch statements - - fatcontext # detects nested contexts in loops + - exportloopref # checks for pointers to enclosing loop variables + - forbidigo # forbids identifiers - funlen # tool for detection of long functions - gocheckcompilerdirectives # validates go compiler directive comments (//go:) + #- gochecknoglobals # checks that no global variables exist - gochecknoinits # checks that no init functions are present in Go code - gochecksumtype # checks exhaustiveness on Go "sum types" - gocognit # computes and checks the cognitive complexity of functions - goconst # finds repeated strings that could be replaced by a constant - gocritic # provides diagnostics that check for bugs, performance and style issues - gocyclo # computes and checks the cyclomatic complexity of functions + #- godot # checks if comments end in a period - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt + #- gomnd # detects magic numbers - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod - gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations - goprintffuncname # checks that printf-like functions are named with f at the end - gosec # inspects source code for security problems - - intrange # finds places where for loops could make use of an integer range - - lll # reports long lines + #- lll # reports long lines - loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap) - makezero # finds slice declarations with non-zero initial length - mirror # reports wrong mirror patterns of bytes/strings usage - - musttag # enforces field tags in (un)marshaled structs + #- musttag # enforces field tags in (un)marshaled structs - nakedret # finds naked returns in functions greater than a specified function length - nestif # reports deeply nested if statements - nilerr # finds the code that returns nil even if it checks that the error is not nil - nilnil # checks that there is no simultaneous return of nil error and an invalid value - noctx # finds sending http request without context.Context + - nolintlint # reports ill-formed or insufficient nolint directives - nonamedreturns # reports all named returns - nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL - perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative @@ -269,12 +244,12 @@ linters: - revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint - rowserrcheck # checks whether Err of rows is checked successfully - sloglint # ensure consistent code style when using log/slog - - spancheck # checks for mistakes with OpenTelemetry/Census spans - sqlclosecheck # checks that sql.Rows and sql.Stmt are closed - stylecheck # is a replacement for golint - tenv # detects using os.Setenv instead of t.Setenv since Go1.17 - testableexamples # checks if examples are testable (have an expected output) - testifylint # checks usage of github.com/stretchr/testify + #- testpackage # makes you use a separate _test package - tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes - unconvert # removes unnecessary type conversions - unparam # reports unused function parameters @@ -304,30 +279,34 @@ linters: #- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages #- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) #- dupword # [useless without config] checks for duplicate words in the source code - #- err113 # [too strict] checks the errors handling expressions #- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted - #- execinquery # [deprecated] checks query string in Query function which reads your Go src files and warning it finds - #- exportloopref # [not necessary from Go 1.22] checks for pointers to enclosing loop variables - #- forbidigo # forbids identifiers #- forcetypeassert # [replaced by errcheck] finds forced type assertions - #- gochecknoglobals # checks that no global variables exist - #- godot # checks if comments end in a period + #- goerr113 # [too strict] checks the errors handling expressions #- gofmt # [replaced by goimports] checks whether code was gofmt-ed #- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed #- gosmopolitan # reports certain i18n/l10n anti-patterns in your Go codebase #- grouper # analyzes expression groups #- importas # enforces consistent import aliases - #- nolintlint # reports ill-formed or insufficient nolint directives, disable because breaks the rules of gofmt #- maintidx # measures the maintainability index of each function #- misspell # [useless] finds commonly misspelled English words in comments - #- mnd # detects magic numbers #- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity #- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test #- tagliatelle # checks the struct tags - #- testpackage # makes you use a separate _test package #- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers #- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines + ## deprecated + #- deadcode # [deprecated, replaced by unused] finds unused code + #- exhaustivestruct # [deprecated, replaced by exhaustruct] checks if all struct's fields are initialized + #- golint # [deprecated, replaced by revive] golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes + #- ifshort # [deprecated] checks that your code uses short syntax for if-statements whenever possible + #- interfacer # [deprecated] suggests narrower interface types + #- maligned # [deprecated, replaced by govet fieldalignment] detects Go structs that would take less memory if their fields were sorted + #- nosnakecase # [deprecated, replaced by revive var-naming] detects snake case of variable naming and function name + #- scopelint # [deprecated, replaced by exportloopref] checks for unpinned variables in go programs + #- structcheck # [deprecated, replaced by unused] finds unused struct fields + #- varcheck # [deprecated, replaced by unused] finds unused global variables and constants + issues: # Maximum count of issues with the same text. @@ -336,6 +315,12 @@ issues: max-same-issues: 50 exclude-rules: + - path: resolve.go + linters: + - typecheck + - path: rdt_visitor.go + linters: + - typecheck - source: "(noinspection|TODO)" linters: [ godot ] - source: "//noinspection" @@ -348,13 +333,4 @@ issues: - goconst - gosec - noctx - - wrapcheck - - gocognit - - lll - - revive - - staticcheck - - asasalint - - gocyclo - - errcheck - - cyclop - - nonamedreturns \ No newline at end of file + - wrapcheck \ No newline at end of file diff --git a/Makefile b/Makefile index df12089..ab77c5e 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,15 @@ # Directory containing the Makefile. export PATH := $(GOBIN):$(PATH) +GO_VERISON = 1.20.14 +GOLANGCI_LINT_VERSION = 1.55.2 + .PHONY: all all: lint cover .PHONY: lint lint: - @golangci-lint run ./... + @go$(GO_VERISON) run github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION) run ./... .PHONY: test test-unit: @@ -15,7 +18,8 @@ test-unit: # the coverage should be at least 80% for now, but it should be increased in the future to 90% and more .PHONY: cover test-cover: - @go test -coverprofile=cover.out.tmp -coverpkg=./... ./... \ + @pkgs=$$(go list ./... | grep -v /Store/) \ + go test -coverprofile=cover.out.tmp $${pkgs} -coverpkg=$${pkgs} \ && cat cover.out.tmp | grep -v "rdtparser_base_visitor.go" > cover.out \ && rm cover.out.tmp \ && go tool cover -func=cover.out | grep total | awk '{print substr($$3, 1, length($$3)-1)}' | \ @@ -32,11 +36,8 @@ build: go-build go-build: @cd cmd/raml && go build -o ../../.build/raml -.PHONY: install -install: go-install .PHONY: go-install go-install: - @cd cmd/raml && \ - go install -v ./... \ - && echo $$(go list -f '{{.Module.Path}}') has been installed to $$(go list -f '{{.Target}}') && true \ No newline at end of file + go install golang.org/dl/go$(GO_VERISON)@latest + go$(GO_VERISON) download diff --git a/cmd/raml/go.mod b/cmd/raml/go.mod index c336179..3ed92f8 100644 --- a/cmd/raml/go.mod +++ b/cmd/raml/go.mod @@ -1,6 +1,6 @@ module github.com/acronis/go-raml/cmd/raml -go 1.23.0 +go 1.22.6 require ( github.com/acronis/go-raml v0.14.0 diff --git a/complex.go b/complex.go index f92eb37..5d8cbac 100644 --- a/complex.go +++ b/complex.go @@ -6,8 +6,8 @@ import ( "regexp" "strconv" - "github.com/cespare/xxhash" orderedmap "github.com/wk8/go-ordered-map/v2" + "github.com/zeebo/xxh3" "gopkg.in/yaml.v3" "github.com/acronis/go-stacktrace" @@ -77,7 +77,7 @@ func hashInterfaceFast(v interface{}) (uint64, error) { } // Use xxhash for fast hashing. - return xxhash.Sum64(data), nil + return xxh3.Hash(data), nil } func (s *ArrayShape) validate(v interface{}, ctxPath string) error { diff --git a/go.mod b/go.mod index 476496d..b4e8484 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,26 @@ module github.com/acronis/go-raml -go 1.20.6 +go 1.20 require ( github.com/acronis/go-stacktrace v0.4.0 github.com/antlr4-go/antlr/v4 v4.13.0 - github.com/cespare/xxhash v1.1.0 github.com/stretchr/testify v1.9.0 github.com/wk8/go-ordered-map/v2 v2.1.8 + github.com/zeebo/xxh3 v1.0.2 gopkg.in/yaml.v3 v3.0.1 ) require ( github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/rogpeppe/go-internal v1.13.1 // indirect golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect + golang.org/x/sys v0.28.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum index e920a20..4c951b6 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/acronis/go-stacktrace v0.4.0 h1:rL+6LxDnQ1/KcaCvF6ftC1Hjg91rjuPjPxS7+xH81xk= github.com/acronis/go-stacktrace v0.4.0/go.mod h1:7Yf4nTbD//u5yR21BhiLzitxh8lU8Vb8SakHhoRAyqQ= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= @@ -8,24 +6,41 @@ github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPn github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= +github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= +github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= +github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/parse.go b/parse.go index 040be0f..a50be10 100644 --- a/parse.go +++ b/parse.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "log" - "log/slog" "os" "path/filepath" "strings" @@ -224,7 +223,7 @@ func (r *RAML) parseLibrary(path string) (*Library, error) { var err error if lib := r.GetFragment(path); lib != nil { - slog.Debug("reusing fragment", slog.String("path", path)) + // slog.Debug("reusing fragment", slog.String("path", path)) return lib.(*Library), nil } @@ -274,7 +273,7 @@ func (r *RAML) parseNamedExample(path string) (*NamedExample, error) { // Convert rel to abs relative to current workdir if necessary. if lib := r.GetFragment(path); lib != nil { - slog.Debug("reusing fragment", slog.String("path", path)) + // slog.Debug("reusing fragment", slog.String("path", path)) return lib.(*NamedExample), nil } diff --git a/parse_test.go b/parse_test.go index 5904a15..cf34c6d 100644 --- a/parse_test.go +++ b/parse_test.go @@ -5,7 +5,6 @@ import ( "context" "errors" "io" - "log/slog" "os" "runtime" "testing" @@ -20,8 +19,7 @@ func Test_ParseFromPathIntegration(t *testing.T) { require.NoError(t, err) elapsed := time.Since(start) shapesAll := rml.GetShapes() - slog.Info("ParseFromPath", "took ms", elapsed.Milliseconds(), "location", - rml.entryPoint.GetLocation(), "total shapes", len(shapesAll)) + t.Logf("ParseFromPath took %d ms, location %s, total shapes %d", elapsed.Milliseconds(), rml.entryPoint.GetLocation(), len(shapesAll)) for _, base := range shapesAll { shape := base.Shape @@ -84,8 +82,8 @@ func printMemUsage(t *testing.T) { var m runtime.MemStats t.Helper() runtime.ReadMemStats(&m) - slog.Info("Memory usage", "alloc MiB", m.Alloc/1024/1024, "total alloc MiB", - m.TotalAlloc/1024/1024, "sys MiB", m.Sys/1024/1024, "num GC", m.NumGC) + t.Logf("Memory usage: alloc MiB %d, total alloc MiB %d, sys MiB %d, num GC %d", + m.Alloc/1024/1024, m.TotalAlloc/1024/1024, m.Sys/1024/1024, m.NumGC) } type mockReadSeeker struct {