MCPcopy Create free account
hub / github.com/astercloud/aster / LoadData

Method LoadData

pkg/tools/builtin/storage_manager.go:124–135  ·  view source on GitHub ↗

LoadData 加载数据

(key string, target any)

Source from the content-addressed store, hash-verified

122
123// LoadData 加载数据
124func (fsm *FileStorageManager) LoadData(key string, target any) error {
125 fsm.mu.RLock()
126 defer fsm.mu.RUnlock()
127
128 filePath := filepath.Join(fsm.dataDir, key+".json")
129 data, err := os.ReadFile(filePath)
130 if err != nil {
131 return fmt.Errorf("failed to read file: %w", err)
132 }
133
134 return json.Unmarshal(data, target)
135}
136
137// DeleteData 删除数据
138func (fsm *FileStorageManager) DeleteData(key string) error {

Callers

nothing calls this directly

Calls 2

JoinMethod · 0.45
ReadFileMethod · 0.45

Tested by

no test coverage detected