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

Installing gorilla/mux

Follow these steps to install the mux package:

  1. You need to run this command in the Terminal (Mac OS X and Linux):
go get -u github.com/gorilla/mux
  1. If you get any errors saying package github.com/gorilla/mux: cannot download, $GOPATH not set. For more details see--go help gopath, set the $GOPATH environment variable using the following command:
export GOPATH=~/go
  1. As we discussed in Chapter 1Getting Started with REST API Development, all the packages and programs go into GOPATH. It has three folders: bin, pkg, and src. Now, add GOPATH to the PATH variable to use the installed bin files as system utilities that have no ./executable style. Refer to the following command:
PATH="$GOPATH/bin:$PATH"
  1. These settings stay until you turn off your machine. So, to make it a permanent change, add the preceding line to your bash/zsh profile file:
vi ~/.profile
(or)
vi ~/.zshrc

We can import gorilla/mux in our programs, like this:

import "github.com/gorilla/mux"

Now, we are ready to go. Assuming gorilla/mux is installed, we can now explore its basics.

主站蜘蛛池模板: 栾城县| 皋兰县| 台北市| 海南省| 乐业县| 武平县| 巴马| 谷城县| 佳木斯市| 嵊泗县| 武邑县| 蕉岭县| 鄂伦春自治旗| 松阳县| 壤塘县| 黄龙县| 广丰县| 中宁县| 瑞金市| 精河县| 洮南市| 南昌市| 靖边县| 台州市| 揭阳市| 临夏市| 固阳县| 澄江县| 无极县| 宣武区| 河北区| 湘潭县| 福泉市| 吴忠市| 舟曲县| 韩城市| 鹤山市| 久治县| 石河子市| 浮山县| 阳曲县|