feat(go-config): multi-format codecs, envc CLI, fixtures, ASRs
- Module github.com/eslider/go-config with env/yaml/json/ini packages - internal: source, keymap, merge, structconv, bytesutil - cmd/envc: convert, get, merge - docs/asr ASR-0001..0008, README/CHANGELOG/AGENTS refresh - golangci-lint v2 config; tests + fixtures Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/eslider/go-config/internal/source"
|
||||
)
|
||||
|
||||
func openSource(pathOrURL string, stdin io.Reader) source.Source {
|
||||
if pathOrURL == "" || pathOrURL == "-" {
|
||||
return source.Reader{R: stdin, Name: "stdin"}
|
||||
}
|
||||
if strings.HasPrefix(pathOrURL, "http://") || strings.HasPrefix(pathOrURL, "https://") {
|
||||
return source.URL{Raw: pathOrURL}
|
||||
}
|
||||
return source.File{Path: pathOrURL}
|
||||
}
|
||||
|
||||
type nopCloser struct{ io.Writer }
|
||||
|
||||
func (nopCloser) Close() error { return nil }
|
||||
|
||||
func openOutput(path string, stdout io.Writer) (io.WriteCloser, error) {
|
||||
if path == "" || path == "-" {
|
||||
if wc, ok := stdout.(io.WriteCloser); ok {
|
||||
return wc, nil
|
||||
}
|
||||
return nopCloser{stdout}, nil
|
||||
}
|
||||
return os.Create(path)
|
||||
}
|
||||
Reference in New Issue
Block a user