When I run the following code (it's supposed to reverse the contents of a string), I get strange errors from the compiler.
package main
import "fmt"
func main(){
argString := "I am a string"
arrayPointer := len(argString)
outputString := "string"
for arrayPointer >= 0 ; arrayPointer-- {
outputString := fmt.Sprintf("%s%s", outputString, argString[arrayPointer])
}
}
It throws the following errors:
prog.go:9: syntax error: missing { after for clause
prog.go:12: syntax error: unexpected }
[process exited with non-zero status]
I've used this syntax before (unless I'm missing something), and I've never seen errors from it. What am I missing?
arrayPointer := len(argString);
– John3136