Effective Go Recipes: Minor question in Recipe 7, page 18

Any reason why

locPrefix := []byte("loc:{")
...
i += len(locPrefix) - 1

can’t be replaced by

locPrefix := []byte("loc:")
...
i += len(locPrefix)

I seem to get the same output with both.

Good question :slight_smile: When parsing, I try to be as specific as possible. There’s a small chance that there’s loc: without the { and I want to ignore it.

1 Like

Ok. Thanks.