
This basic concept, which happens to be at the heart of the structuring, construction of programs written in GO language. If we look closer we can see that the whole code of the standard library is in the form of package. More globally all programs are packages and are related or not together. For example, we could group under a package a functional unit concerning invoice editing. Another on customer management. One could have this reasoning at a more technical level like the standard GO library.
The Basic Concept: Packages, is fundamental to having a sound and easily scalable and clear software architecture. I will present a demonstration on the creation and use of a package later.
We find this concept in many other languages, with different names, as in CSharp, Java, C++, etc…
package main import ( "fmt" ) func main() { fmt.Println("Hello, playground") }
If we go back to our basic example, we notice that the first line is the declaration of the name of the package to which the code belongs here in our case main.
We will see later that the main function is important. It is theenter point of your application, program.
Allows the definition of a set of functions, constants, variables, declarations in the same scope.
Writing a package can be done on several source files. Go will only reason at the package level.
package
math package
The package name should not have a space in its name. This is the first instruction found in a GO source file.