MCPcopy
hub / github.com/golang-jwt/jwt / loadData

Function loadData

cmd/jwt/main.go:78–100  ·  view source on GitHub ↗

Helper func: Read input from specified file or stdin

(p string)

Source from the content-addressed store, hash-verified

76
77// Helper func: Read input from specified file or stdin
78func loadData(p string) (_ []byte, retErr error) {
79 if p == "" {
80 return nil, fmt.Errorf("no path specified")
81 }
82
83 var rdr io.Reader
84 switch p {
85 case "-":
86 rdr = os.Stdin
87 case "+":
88 return []byte("{}"), nil
89 default:
90 f, err := os.Open(p)
91 if err != nil {
92 return nil, err
93 }
94 rdr = f
95 defer func() {
96 retErr = errors.Join(retErr, f.Close())
97 }()
98 }
99 return io.ReadAll(rdr)
100}
101
102// Print a json object in accordance with the prophecy (or the command line options)
103func printJSON(j any) error {

Callers 3

verifyTokenFunction · 0.85
signTokenFunction · 0.85
showTokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected