官术网_书友最值得收藏!

Creating your first package

Within the ~/src directory, any directory you create is a package. The name of your directory becomes the name of the package or application. We need to first make sure that the src directory exists. Tilde (~) is a shortcut for your home directory similar to the $HOME variable. Refer to the following code block:

mkdir ~/src

Let's create a new package named hello for our first application:

cd ~/src
mkdir hello

A package is simply a directory. You can have one or more source files inside a package. Any subdirectories are treated as separate packages. A package can be an application with a main() function (package main), or it can be a library that can only be imported to other packages. This package doesn't have any files yet, but we'll write the first file in a moment. Don't worry too much about package structure for now. You can read more about package paths at https://golang.org/doc/code.html#PackagePaths.

主站蜘蛛池模板: 抚宁县| 牙克石市| 龙岩市| 广灵县| 武汉市| 固始县| 八宿县| 张家口市| 郸城县| 名山县| 尼玛县| 宝山区| 黑河市| 怀宁县| 万安县| 广水市| 响水县| 岫岩| 江城| 宜州市| 五莲县| 宜丰县| 中卫市| 桂平市| 崇文区| 井冈山市| 凉城县| 眉山市| 奉化市| 安塞县| 赞皇县| 峡江县| 凌云县| 赤峰市| 奉新县| 周宁县| 临澧县| 沙洋县| 巧家县| 灵武市| 苗栗县|