Files
go-sip/contracts/contracts.go
T

33 lines
718 B
Go

package contracts
import (
"embed"
"encoding/json"
"fmt"
"path"
)
// Files is the immutable contract bundle imported from the parent repository.
// The bundle is copied from a recorded parent commit; runtime code never reads
// the parent worktree.
//
//go:embed upstream
var Files embed.FS
const SourceCommit = "2026-09-19-p1-v1"
func Read(name string) ([]byte, error) {
return Files.ReadFile(path.Join("upstream", SourceCommit, name))
}
func ReadJSON(name string, dst any) error {
data, err := Read(name)
if err != nil {
return fmt.Errorf("read contract %s: %w", name, err)
}
if err := json.Unmarshal(data, dst); err != nil {
return fmt.Errorf("decode contract %s: %w", name, err)
}
return nil
}