MCPcopy
hub / github.com/grpc/grpc-go / loadSnapshot

Function loadSnapshot

profiling/cmd/local.go:27–45  ·  view source on GitHub ↗
(snapshotFileName string)

Source from the content-addressed store, hash-verified

25)
26
27func loadSnapshot(snapshotFileName string) (*snapshot, error) {
28 logger.Infof("opening snapshot file %s", snapshotFileName)
29 snapshotFile, err := os.Open(snapshotFileName)
30 if err != nil {
31 logger.Errorf("cannot open %s: %v", snapshotFileName, err)
32 return nil, err
33 }
34 defer snapshotFile.Close()
35
36 logger.Infof("decoding snapshot file %s", snapshotFileName)
37 s := &snapshot{}
38 decoder := gob.NewDecoder(snapshotFile)
39 if err = decoder.Decode(s); err != nil {
40 logger.Errorf("cannot decode %s: %v", snapshotFileName, err)
41 return nil, err
42 }
43
44 return s, nil
45}
46
47func localCommand() error {
48 if *flagSnapshot == "" {

Callers 1

localCommandFunction · 0.85

Calls 5

DecodeMethod · 0.95
OpenMethod · 0.80
InfofMethod · 0.65
ErrorfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected