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

removed golang x package in favour of the std lib #303

Merged
merged 1 commit into from
Jul 8, 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
4 changes: 2 additions & 2 deletions datamodel/low/extraction_functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"strings"
"testing"

"golang.org/x/sync/syncmap"
"gopkg.in/yaml.v3"

"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"sync"
)

func TestFindItemInOrderedMap(t *testing.T) {
Expand Down Expand Up @@ -1901,7 +1901,7 @@ func TestLocateRefNode_DoARealLookup(t *testing.T) {
idx := index.NewSpecIndexWithConfig(&rootNode, cf)

// fake cache to a lookup for a file that does not exist will work.
fakeCache := new(syncmap.Map)
fakeCache := new(sync.Map)
fakeCache.Store(lookup, &index.Reference{Node: &no, Index: idx})
idx.SetCache(fakeCache)

Expand Down
2 changes: 1 addition & 1 deletion document_iteration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"slices"
)

type loopFrame struct {
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ require (
github.com/stretchr/testify v1.8.4
github.com/vmware-labs/yaml-jsonpath v0.3.2
github.com/wk8/go-ordered-map/v2 v2.1.8
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
golang.org/x/sync v0.6.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
Expand All @@ -87,8 +85,6 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion index/extract_refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"

"github.com/pb33f/libopenapi/utils"
"golang.org/x/exp/slices"
"slices"
"gopkg.in/yaml.v3"
)

Expand Down
9 changes: 4 additions & 5 deletions index/index_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"sync"

"github.com/pb33f/libopenapi/datamodel"
"golang.org/x/sync/syncmap"

"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -236,7 +235,7 @@ type SpecIndex struct {
allRefSchemaDefinitions []*Reference // all schemas found that are references.
allInlineSchemaDefinitions []*Reference // all schemas found in document outside of components (openapi) or definitions (swagger).
allInlineSchemaObjectDefinitions []*Reference // all schemas that are objects found in document outside of components (openapi) or definitions (swagger).
allComponentSchemaDefinitions *syncmap.Map // all schemas found in components (openapi) or definitions (swagger).
allComponentSchemaDefinitions *sync.Map // all schemas found in components (openapi) or definitions (swagger).
securitySchemesNode *yaml.Node // components/securitySchemes node
allSecuritySchemes map[string]*Reference // all security schemes / definitions.
requestBodiesNode *yaml.Node // components/requestBodies node
Expand Down Expand Up @@ -273,7 +272,7 @@ type SpecIndex struct {
componentIndexChan chan bool
polyComponentIndexChan chan bool
resolver *Resolver
cache *syncmap.Map
cache *sync.Map
built bool
uri []string
logger *slog.Logger
Expand All @@ -292,15 +291,15 @@ func (index *SpecIndex) GetConfig() *SpecIndexConfig {
return index.config
}

func (index *SpecIndex) SetCache(sync *syncmap.Map) {
func (index *SpecIndex) SetCache(sync *sync.Map) {
index.cache = sync
}

func (index *SpecIndex) GetNodeMap() map[int]map[int]*yaml.Node {
return index.nodeMap
}

func (index *SpecIndex) GetCache() *syncmap.Map {
func (index *SpecIndex) GetCache() *sync.Map {
return index.cache
}

Expand Down
2 changes: 1 addition & 1 deletion index/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"

"github.com/pb33f/libopenapi/utils"
"golang.org/x/exp/slices"
"slices"
"gopkg.in/yaml.v3"
)

Expand Down
6 changes: 3 additions & 3 deletions index/rolodex_file_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"time"

"github.com/pb33f/libopenapi/datamodel"
"golang.org/x/sync/syncmap"
"gopkg.in/yaml.v3"
"sync"
)

// LocalFS is a file system that indexes local files.
Expand All @@ -25,12 +25,12 @@ type LocalFS struct {
indexConfig *SpecIndexConfig
entryPointDirectory string
baseDirectory string
Files syncmap.Map
Files sync.Map
extractedFiles map[string]RolodexFile
logger *slog.Logger
readingErrors []error
rolodex *Rolodex
processingFiles syncmap.Map
processingFiles sync.Map
}

// GetFiles returns the files that have been indexed. A map of RolodexFile objects keyed by the full path of the file.
Expand Down
10 changes: 5 additions & 5 deletions index/rolodex_remote_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (

"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/utils"
"golang.org/x/sync/syncmap"
"gopkg.in/yaml.v3"
"sync"
)

const (
Expand All @@ -38,8 +38,8 @@ type RemoteFS struct {
rootURL string
rootURLParsed *url.URL
RemoteHandlerFunc utils.RemoteURLHandler
Files syncmap.Map
ProcessingFiles syncmap.Map
Files sync.Map
ProcessingFiles sync.Map
FetchTime int64
FetchChannel chan *RemoteFile
remoteErrors []error
Expand Down Expand Up @@ -344,10 +344,10 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) {
remoteParsedURL.Host = i.rootURLParsed.Host
remoteParsedURL.Scheme = i.rootURLParsed.Scheme
// this has been disabled, because I don't think it has value, it causes more problems than it solves currently.
//if !strings.HasPrefix(remoteParsedURL.Path, "/") {
// if !strings.HasPrefix(remoteParsedURL.Path, "/") {
// remoteParsedURL.Path = filepath.Join(i.rootURLParsed.Path, remoteParsedURL.Path)
// remoteParsedURL.Path = strings.ReplaceAll(remoteParsedURL.Path, "\\", "/")
//}
// }
}

if remoteParsedURL.Scheme == "" {
Expand Down
3 changes: 1 addition & 2 deletions index/spec_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/pb33f/libopenapi/utils"
"github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath"
"golang.org/x/sync/syncmap"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -73,7 +72,7 @@ func createNewIndex(rootNode *yaml.Node, index *SpecIndex, avoidBuildOut bool) *
index.nodeMap = make(map[int]map[int]*yaml.Node)
go index.MapNodes(rootNode) // this can run async.

index.cache = new(syncmap.Map)
index.cache = new(sync.Map)

// boot index.
results := index.ExtractRefs(index.root.Content[0], index.root, []string{}, 0, false, "")
Expand Down
5 changes: 2 additions & 3 deletions index/spec_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import (
"time"

"github.com/pb33f/libopenapi/utils"
"golang.org/x/sync/syncmap"

"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"sync"
)

const (
Expand All @@ -44,7 +43,7 @@ func TestSpecIndex_GetCache(t *testing.T) {
assert.True(t, ok)

// create a new cache
newCache := new(syncmap.Map)
newCache := new(sync.Map)
index.SetCache(newCache)

// check that the cache has been set.
Expand Down
2 changes: 1 addition & 1 deletion renderer/schema_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/lucasjones/reggen"
"github.com/pb33f/libopenapi/datamodel/high/base"
"github.com/pb33f/libopenapi/orderedmap"
"golang.org/x/exp/slices"
"slices"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion what-changed/model/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sort"
"sync"

"golang.org/x/exp/slices"
"slices"

"github.com/pb33f/libopenapi/datamodel/low"
"github.com/pb33f/libopenapi/datamodel/low/base"
Expand Down
Loading