I am a totally new Golang developer, But I am facing some problem while using VSCODE. It's it's happening from time to time. It's giving me a lot of headache sometimes to debug my code. I am not sure how to fix this issue. I am adding two images for reference ,
The first Image, There is an invalid character
Then, I have opened the same file with another editor, And here is what I got
Same Code with another Editor
The problem is, This is happening automatically. I am not sure where the problem is. If you have a solution about how to avoid this without changing my editor , Please let me know.
Thank you in advance.
CodePudding user response:
(Firstly, please include the source code in your questions - I know you wanted to show the syntax highlighting - but it helps to reproduce the problem)
Your original code has many issues stemming from mismatched types etc.
Fixing some of these, enables the code to compile/run:
func main() {
k := 3 // int
b := 2.5 // float64
var g float32
g = float32(k) * float32(b) // need type conversion to get desired float32
fmt.Println(g) // reference g - to avoid "g declared but not used" go vet error
}
https://go.dev/play/p/XQCEMya-BlN
CodePudding user response:
SOLVED This problem was solved by @colm-anseo This is most likely not related to hidden Unicode characters - but since Go source is UTF-8 compliant, "gremlin" characters can sneak in (typically when cut-n-pasting from the web). This extension For VSCODE can solve the problem and can detect those unwanted "gremlin" characters