I can't compile

I’m trying to compile, hello world, and the message pops up: Go package name is empty, can anyone help me?

Perhaps…

But to make us able to help you, you need to provide more details.

What’s the content of your source file, how do you compile it?

Selecione cannot be posted, anda there are no recent releases

Does it work if you use go run instead of eclipse?

Is it by the terminal? I was able to compile, but I think I deleted some folder, or package, or file, I don’t know, so it didn’t compile anymore, I think Eclipse is not a good IDE, to program GO

And when you use go run from the terminal, what output do you see?

The code as per your first screenshot looks as if it should work. Though it’s hard to tell from a mobile phone, perhaps copy and paste into the forum the next time?

Perhaps give PSA Make it easier to help you a read?

1 Like

package main

import “fmt”

func main() {
fmt.Println(“Hello, 世界”)
} on the go site, compile, on the go run terminal, go run
go run: no go files listed

We already went through this, when using go run you need to provide the file name.

Also please use triple-backtick when posting code.

How do I know the file name? What is triple-backtick?

You saved the file with a name, so you know it from that point in time.

And tripple-backtick is three backticks at the start of a code block and three backticks at the end, as described in the PSA I linked earlier.

The file name is olamundo, func add (x, y int) int {
return x + y
}, this block, have to put at the beginning of the code, or replace in the code, I read, but it was not very clear, should I put go run olamundo?

Per the screenshot the name of the file is “olamundo.go”.

And I’m not sure where that add function comes from.

Make sure you get your hello world working first, before trying to add functionality.

package main

import (
“fmt”
)

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

func add(x, y int) int {
return x + y
} Please explain to me, is PSA used this way?

In the terminal, put olamundo.go?

PSA is short for “Public Service Announcement”, I’ve linked to it above, just read it. It explains all the important stuff how to use the forum and markdown.

As I’ve explained in your previous threads, first use cd to navigate to the folder that contains the sources, then use go run <filename> (where <filename> is the actual name of the file) to compile and run your program.

go run olamundo
go run: no go files listed

As I said, per the screenshot the name is olamundo.go, the .go suffix is part of the filename.

go run: no go files listed
go: unknown subcommand “run:”
Run ‘go help’ for usage.
I put the .go but it was not found