How does the go language distinguish packages, files, and folders?

how does the go language distinguish packages, files, and folders?
for example, there is a file:
d:\ workspace\ www\ go_work\ src\ project_01\ hello.go

package main

import "fmt"

func main(){
  fmt.Println("hello")
}

look at the tutorial and say that the program must have a main package. question:

in the above example, the file name is hello.go , and package says main , but there is no actual main package. What exactly does the package mean? It doesn"t seem to be a file or folder, either, because there is no main file or folder.

Sep.29,2021

take the package gorilla/websocket as an example, and
download it to the local src and reference him

.
 

A package consists of one or more source files, each of which can access the contents of the package (including variables, constants, types, functions, etc.). The organization at the source file level is the folder, which usually puts all the source files of a package in one folder.

The

main package is special because it must contain a main function; and it must be in the root directory of the program.

so:

you ask what the bag is. At the program level, a package is a code module made up of all source files that use the same package < package-name > ; at the source file level, it is a folder.

< hr >

the source code organization of go may be somewhat different from other languages. If the beginner's words can not be understood at once, then you don't have to think too much. After in-depth study, you will understand more of other people's code.

in addition, it is important to read more official documents, which also have a very detailed description of the organization of the source code

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3cd15-2c35b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3cd15-2c35b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?