Bhimra

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2021 License: MIT Imports: 1 Imported by: 0

README

DAY 1

    package hello  // package name hello   
    import (
        "fmt"
    )
    func Hello() {
        fmt.Println(" run if you can")
    }

Above code showed a ERROR : "go run: cannot run non-main package" due to package name is not main.

  • To fix it, I just need to name the package to main. But I don't understand why I need to do that. I should be able to name the package whatever I want.
  • Another question, I know main function is the entry point of the program, you need it. otherwise it will not work. But I see some codes that didn't have main function still works.
  • Click on this link, the example at the bottom of the page didn't use package main and main function, and it still works. just curious

    WHY?

go to this link

Resolving issue:

You need to specify in your app.yaml file what your app access point is. You need to specify
application: hello

-The entry point of each go program is main.main, i.e. a function called main in a package called main. You have to provide such a main package.
- GAE is an exception though. They add a main package, containing the main function automatically to your project. Therefore, you are not allowed to write your own.

Documentation

Overview

Declare a main package//

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL