O Go, não compila "hello world"

You do not know how to do what?

Opening a terminal?
Using cd to navigate to the folder that contains your sources?
Running a modified to your needs go run filename?
Showing us the output of that command?
Getting a files content on screen via cat filename?

I’m happy to guide you as best as I can, but as I do not have access to your system, you will have to fill in the gaps for me, like filenames and pathes.

If you do not know how to copy and paste what you see in your terminal, thats fine, just upload a screenshot.

No. The terminal is a program that uses commands given on a prompt to do things. The “old” way. Without mouse and click. Just with keyboard.

From the screenshot it seems as if you even had one open. The black square with the silver border and the greater than sign (>).

In my opinion one should learn basic usage of the terminal and bash and not rely on IDEs to magically do the right thing.

I can open the terminal, I just can’t find a filename, I cd, then go run, I don’t know the filename, because I don’t know which file you want to see.

I can use very little terminal, I don’t know how to give commands.

You said you wanted to run the code you have already written in eclipse. So only you know where that file is stored. And exactly that’s the place where you need to cd into.

That file is what we need to see.

Also we need to know it’s name, it’s location and the command you use to run it using go run.

I think that’s olamundo

You can not use that package name for a program you want to run. Runnable programs are required to have package main and also a main function. Your package has the wrong name.

Yesterday, I couldn’t answer anymore, because I ran out of replies for the first day in the forum. Is the file name wrong then? The name is causing it not to compile?

The package name. As I said, the first line has to be package main for runnable programs.

And how do I change?

Use your keyboard to change the first line in your sourcefile.

Pretty much like you created that file in the first place, but the first line having a different package name.

It is?


The first line of your source file. The big edit view in the center of your IDE contains currently this:

package olamundo

import "fmt"

func main() {
    fmt.Println("hello world")

And now you have to change the very first line into package main which currently says package olamundo.

What is the next step?

go run name_of_the_file.go, from where the file lives in your terminal. I have no clue about how you would do it in eclipse.

It was the name, now compiled.

Thank you for helping me.

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