package cgf import ( "encoding/json" "fmt" "io" "os" "git.wecise.com/wecise/cgimport/cgf/reader" ) func Import(filepath string) (blockcount int, err error) { f, e := os.Open(filepath) if e != nil { return blockcount, e } defer f.Close() return importReader(f) } func importReader(buf io.Reader) (blockcount int, err error) { br := reader.NewBlockReader(buf) for { block, e := br.ReadBlock() if e != nil { return blockcount, e } if block == nil { return } e = importBlock(block) if e != nil { return blockcount, e } blockcount++ } } func importBlock(block map[string]any) (err error) { bs, e := json.MarshalIndent(block, "", " ") if e != nil { return e } fmt.Println("import:", string(bs)) return }