File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ The plugin ecosystem consists of several interconnected components:
3232** Purpose** : Provides the core interface and types for plugin development.
3333
3434** Key Files** :
35- - ` plugin.go ` - Core Plugin interface and supporting types
36- - ` BasePlugin ` - Default implementation for common functionality
35+ - ` plugin.go ` - Core ` Plugin ` interface, ` BasePlugin ` , and supporting types
3736- ` stdio.go ` - Shared stdin/stdout JSON loop (` RunStdio ` , ` RunIO ` ) and ` HandlePluginRequest ` for init/message/command/shutdown
3837
3938** Features** :
Original file line number Diff line number Diff line change @@ -288,9 +288,19 @@ type Config struct {
288288Plugins can store data in their data directory:
289289
290290``` go
291+ import (
292+ " encoding/json"
293+ " os"
294+ " path/filepath"
295+ )
296+
291297func (p *MyPlugin ) saveData (data interface {}) error {
292- dataFile := filepath.Join (p.config .DataDir , " data.json" )
293- return os.WriteFile (dataFile, data, 0644 )
298+ dataFile := filepath.Join (p.GetConfig ().DataDir , " data.json" )
299+ b , err := json.Marshal (data)
300+ if err != nil {
301+ return err
302+ }
303+ return os.WriteFile (dataFile, b, 0644 )
294304}
295305```
296306
You can’t perform that action at this time.
0 commit comments