Error when I type go run filename.go

Hello friends!!!
I am new in this forum and in Go progeamming.

I made a “Hello World” first program in go. My code:

package main
import “fmt”

func main(){
fmt.Println(“Hello, everybody!”)
}

I used the classic Windows notepad to write the code.
Then in the cmd shell I access to the folder where I have the .go file and I type:

go run prueba1.go and I get several errors and I am not commiting sintax errors in my sourcw code.


(This is the image of my console showing these error messages!). Please, see ut and tell me what is causing these errors and how to fix it. I have Windows 10 in my computer. Thanks! - Nicolás Matías Funtalas.

Hi Nicolás,

Actually, you are making syntax errors! You used the wrong kind of double quotes. They may look ok, but they are not.

Here is your code at the Go Playground: https://play.golang.org/p/_gOZ-SyYqDX

You can click on the Run button to run it, and see the errors.

The proper double quote is the one that is the same as in ASCII character set,
which is this -> "
It’s the U+022 code point (I hope I got that right). An “interpreted string literal” in Go uses the same character at the start and end of the string.

I don’t know what country you are in and what language you are using, but I’m guessing that there is are double quote keys on your keyboard that look the same to you, and you used those. It’s an easy mistake, of course.

I got completely different errors when compiling your program in the Go Playground or on Linux. I don’t know why.

I tried to check it with Playground and I didn’t get errors. Everything worñed fine!:

package main

import “fmt”

func main(){
fmt.Println(“Hola a todos!. Bienvenidos a GOLANG”)
}

When I try to run it with go run command I get these error messages. Rare!!!

I copied and pasted again, and I get the same errors:

can’t load package: package main:
prog.go:3:8: illegal character U+201C ‘“’
prog.go:3:14: illegal character U+201D ‘”’
prog.go:6:13: illegal character U+201C ‘“’
prog.go:6:51: illegal character U+201D ‘”’

Maybe on your computer, when you copied and pasted, it turned the U+201C and U+201D into U+022 ? Or maybe the copy and paste operation changed the quotes when you posted here? I don’t know! Weird!

The quotes are changed by the forum when not using a code block. Also they are unrelated to the problem.

For me it looks as if the go installation is broken, since all errors are pointing to files in the GOROOT.

I took a closer look.

Go 1.10 had a file hashmap.go, this is not there in Go 1.11. Its the other way round for the file map.go.

So my assumption is, that @nicolas2018alcubo tried to upgrade by simply merging folders, when he should have deleted the old installation first.

Removing and reinstalling is probably the sanest way to fix this.

1 Like

Excuse me, but I installed Go for the first time!. I was not overwriting!. It’s weird. I am goint to delete Go and re-install it to try to fix this annoying problem!!!

How have you installed go? Perhaps the installer is broken then?

By downloading the installer from the official Golang Website and executing the installer

I didn’t get errors during the installation and everything went good!!!

I uninstalled Golang. Re-installed it and I get the same errors!

Norbert, thanks for the correction, and sorry about my mistake.

I’ll check on a windows box tomorrow when I’m in office.

Thank you. Maybe a previous version of Goland could fix it. But well, check it

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.