"main redeclared in this block" see details

Hey guys, I have been learning Go for a few days now, and I stumbled across this error while coding:

main redeclared in this block (see details) 

I’m not sure what it means, but this is my code:

package main

import "fmt"

func main() { // Where error is, specifically main()
	fmt.Println(1 + 1)
	fmt.Println(1 - 1)
	fmt.Println(1 * 200)
	fmt.Println(200/20)

	fmt.Println(true || false)
	fmt.Println(!true)
	fmt.Println(true && false)
}

If anyone could help me with this, it would be great! Thanks so much in advance!

Do you have another .go files in your folder ? If so, check if you create a main() function in each of those files…

You can also use Go Playground ( Go Playground - The Go Programming Language ) just to check your main function…

Yes, I do have another file in the same directory with the main() function. Why does this affect go at all?

Thanks so much! You are a big help!

Ask a free AI, and you will get a complete reply.