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

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.

主站蜘蛛池模板: 广安市| 达拉特旗| 南部县| 安陆市| 元氏县| 青川县| 西乌| 嵊泗县| 横峰县| 凤城市| 平凉市| 南漳县| 铁岭市| 玉树县| 阳谷县| 霍州市| 花垣县| 漾濞| 莒南县| 涞水县| 绥宁县| 宿松县| 大渡口区| 五原县| 资源县| 西宁市| 中阳县| 阜阳市| 德化县| 平阴县| 盖州市| 湘西| 德兴市| 沙洋县| 盐津县| 措美县| 南阳市| 长白| 克山县| 淮滨县| 灯塔市|