(data []byte, location *url.URL)
| 186 | } |
| 187 | |
| 188 | func (loader *Loader) loadFromDataWithPathInternal(data []byte, location *url.URL) (*T, error) { |
| 189 | if loader.visitedDocuments == nil { |
| 190 | loader.visitedDocuments = make(map[string]*T) |
| 191 | loader.rootLocation = location.Path |
| 192 | } |
| 193 | uri := location.String() |
| 194 | if doc, ok := loader.visitedDocuments[uri]; ok { |
| 195 | return doc, nil |
| 196 | } |
| 197 | |
| 198 | doc := &T{} |
| 199 | loader.visitedDocuments[uri] = doc |
| 200 | |
| 201 | if err := unmarshal(data, doc, loader.IncludeOrigin, location); err != nil { |
| 202 | return nil, err |
| 203 | } |
| 204 | |
| 205 | doc.url = copyURI(location) |
| 206 | |
| 207 | if err := loader.ResolveRefsIn(doc, location); err != nil { |
| 208 | return nil, err |
| 209 | } |
| 210 | |
| 211 | return doc, nil |
| 212 | } |
| 213 | |
| 214 | // ResolveRefsIn expands references if for instance spec was just unmarshaled |
| 215 | func (loader *Loader) ResolveRefsIn(doc *T, location *url.URL) (err error) { |
no test coverage detected