Skip to content

Instantly share code, notes, and snippets.

@monmohan
Created May 8, 2021 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monmohan/5d18e70cd12cd2fb05ac3efbb972a820 to your computer and use it in GitHub Desktop.
Save monmohan/5d18e70cd12cd2fb05ac3efbb972a820 to your computer and use it in GitHub Desktop.
func readOps(outfile string) error {
in, err := ioutil.ReadFile(outfile)
if err != nil {
return err
}
instructions := &typedefs.Instructions{}
if err := proto.Unmarshal(in, instructions); err != nil {
return err
}
for _, patch := range instructions.Operations {
switch op := patch.Op.(type) {
case *typedefs.Patch_CopyOp:
fmt.Printf("Copy Operation start: %d, end : %d\n", op.CopyOp.Start, op.CopyOp.End)
case *typedefs.Patch_InsertOp:
fmt.Printf("Insert Operation Rawbytes length: %d\n", len(op.InsertOp.RawBytes))
default:
fmt.Println("No matching operations")
}
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment