Could anyone tell me how to increment a pointer through a string in Go?
I've tried ptr += 1
like in C but it says that the types *string and int are incompatible. Thanks
Could anyone tell me how to increment a pointer through a string in Go?
I've tried ptr += 1
like in C but it says that the types *string and int are incompatible. Thanks
Go FAQ: Why is there no pointer arithmetic?
Safety. Without pointer arithmetic it's possible to create a language that can never derive an illegal address that succeeds incorrectly. Compiler and hardware technology have advanced to the point where a loop using array indices can be as efficient as a loop using pointer arithmetic. Also, the lack of pointer arithmetic can simplify the implementation of the garbage collector.
So the answer is no, you can't increment a pointer in Go.