MCPcopy
hub / github.com/uber-go/zap / newFileSinkFromURL

Method newFileSinkFromURL

sink.go:130–149  ·  view source on GitHub ↗
(u *url.URL)

Source from the content-addressed store, hash-verified

128}
129
130func (sr *sinkRegistry) newFileSinkFromURL(u *url.URL) (Sink, error) {
131 if u.User != nil {
132 return nil, fmt.Errorf("user and password not allowed with file URLs: got %v", u)
133 }
134 if u.Fragment != "" {
135 return nil, fmt.Errorf("fragments not allowed with file URLs: got %v", u)
136 }
137 if u.RawQuery != "" {
138 return nil, fmt.Errorf("query parameters not allowed with file URLs: got %v", u)
139 }
140 // Error messages are better if we check hostname and port separately.
141 if u.Port() != "" {
142 return nil, fmt.Errorf("ports not allowed with file URLs: got %v", u)
143 }
144 if hn := u.Hostname(); hn != "" && hn != "localhost" {
145 return nil, fmt.Errorf("file URLs must leave host empty or use localhost: got %v", u)
146 }
147
148 return sr.newFileSinkFromPath(u.Path)
149}
150
151func (sr *sinkRegistry) newFileSinkFromPath(path string) (Sink, error) {
152 switch path {

Callers

nothing calls this directly

Calls 2

newFileSinkFromPathMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected