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

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.

主站蜘蛛池模板: 涪陵区| 尖扎县| 古交市| 隆德县| 临漳县| 吉隆县| 大方县| 绥中县| 正镶白旗| 肇源县| 鄂托克前旗| 宝应县| 建昌县| 九龙县| 宁国市| 田林县| 松潘县| 长宁区| 揭东县| 新疆| 玉林市| 桦南县| 郴州市| 布拖县| 武平县| 德昌县| 金沙县| 万盛区| 嘉禾县| 沭阳县| 山东省| 屯留县| 雷山县| 甘肃省| 濮阳市| 镇江市| 军事| 宁乡县| 宣化县| 太保市| 乌拉特前旗|