MCPcopy Index your code
hub / github.com/getsops/sops / ExampleFile

Function ExampleFile

decrypt/example_test.go:34–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34func ExampleFile() {
35 var (
36 confPath string = "./example.json"
37 cfg configuration
38 err error
39 )
40 confData, err := File(confPath, "json")
41 if err != nil {
42 log.Fatalf("cleartext configuration marshalling failed with error: %v", err)
43 }
44 err = json.Unmarshal(confData, &cfg)
45 if err != nil {
46 log.Fatalf("cleartext configuration unmarshalling failed with error: %v", err)
47 }
48 if cfg.FirstName != "John" ||
49 cfg.LastName != "Smith" ||
50 cfg.Age != 25.4 ||
51 cfg.PhoneNumbers[1].Number != "646 555-4567" {
52 log.Fatalf("configuration does not contain expected values: %+v", cfg)
53 }
54 log.Printf("%+v", cfg)
55}

Callers

nothing calls this directly

Calls 1

FileFunction · 0.85

Tested by

no test coverage detected