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

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.

主站蜘蛛池模板: 江北区| 丹凤县| 正镶白旗| 丹寨县| 辛集市| 乐安县| 镇坪县| 九龙县| 永昌县| 平舆县| 淮滨县| 奉贤区| 志丹县| 成都市| 建始县| 林甸县| 墨竹工卡县| 富阳市| 大名县| 广德县| 扎囊县| 屏边| 永修县| 望江县| 垫江县| 麻栗坡县| 乌拉特前旗| 津市市| 日土县| 潼关县| 上林县| 南召县| 德兴市| 丰台区| 宜都市| 溧阳市| 九龙城区| 榆树市| 天水市| 昌宁县| 宁津县|