Created
May 8, 2021 07:07
-
-
Save monmohan/5d18e70cd12cd2fb05ac3efbb972a820 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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