Categorygithub.com/fakorede/learning-golanggo-functions01-function-parameters-return-values04-public-private-functions
package
0.0.0-20200526015148-b343531734ec
Repository: https://github.com/fakorede/learning-golang.git
Documentation: pkg.go.dev
# README
Public and Private Functions
Visibility is on a per package level only.
A package is the smallest unit of private encapsulation in Go.
All identifiers defined within a package are visible throughout that package. When importing a package you can access only its exported identifiers.
An identifier is exported if it begins with a capital letter. If an identifier starts with a lower case letter, it can only be accessed from within the package.
Example
Defining the functions Sum
, Divide
and Add
of the expressions.go
starting with capital letters makes them accessible in main.go
.
// Sum : sums up slice values provided as argument.
func Sum(values ...float64) float64 {
}
Usage
Run the program with the command:
go run main.go expressions.go