From the course: Learning Go
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Define and call functions - Go Tutorial
From the course: Learning Go
Define and call functions
- [Instructor] Go is organized with packages and packages have functions. Your application has its own package, always named main. And it has a function also named main that's called its startup. When you define custom functions in your own main file, they're members of the main package. Functions within the same package can be named anything, the initial character can be upper or lowercase, and they don't have to be imported before you can call them from your main file. I'll start with a very simple function. Every function starts with the keyword func and then the name of the function. The name can use camel case spelling such as this. If the initial character is lowercase, it's only available within the current package, and if it's uppercase, it's public to the rest of the application. Within the function. I'll call fmt.Println and I'll put the string, "Doing Something." Now up here, instead of calling print line, I'll call my new function and notice that Visual Studio Code helps…