主頁 > 知識庫 > mac下安裝golang框架iris的方法

mac下安裝golang框架iris的方法

熱門標(biāo)簽:官渡電銷外呼管理系統(tǒng)怎么收費 貴州電話智能外呼系統(tǒng) 赤峰電銷 江蘇呼叫中心外呼系統(tǒng)有效果嗎 400開頭電話怎樣申請 谷歌美發(fā)店地圖標(biāo)注 利用地圖標(biāo)注位置 杭州人工智能電銷機器人費用 地圖區(qū)域圖標(biāo)注后導(dǎo)出

安裝前準(zhǔn)備:

設(shè)置GOPROXY代理

參考:https://goproxy.cn/

我使用的是下面的兩條命令:

$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct

我的go env信息:

% go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mac/Library/Caches/go-build"
GOENV="/Users/mac/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/mac/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mac/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mac/www/iris/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d5/13f52jg52n500y4w_8bxcx680000gn/T/go-build475857461=/tmp/go-build -gno-record-gcc-switches -fno-common"
mac@MacdeMacBook-Pro iris % go env -w GO111MODULE=on
mac@MacdeMacBook-Pro iris % go env -w GOPROXY=https://goproxy.cn,direct
mac@MacdeMacBook-Pro iris % go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mac/Library/Caches/go-build"
GOENV="/Users/mac/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/mac/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mac/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mac/www/iris/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d5/13f52jg52n500y4w_8bxcx680000gn/T/go-build212739672=/tmp/go-build -gno-record-gcc-switches -fno-common"

安裝過程參考:https://www.iris-go.com/docs/#/

創(chuàng)建一個新項目:

% cd ~/www
% mkdir iris 
% cd iris 
% go mod init iris
go: creating new go.mod: module iris
% ls
go.mod
%vim main.go
package main
 
import (
 "github.com/kataras/iris/v12"
)
 
func main() {
 app := iris.New()
 app.Get("/", func(ctx iris.Context) {
  ctx.HTML("h1>Hello World!/h1>")
  app.Logger().Info("我在學(xué)習(xí)Iris噢")
 })
 app.Run(iris.Addr(":8009"))
}

實際安裝過程:

go get -u github.com/kataras/iris/v12@master
 
go: downloading github.com/kataras/iris/v12 v12.2.0-alpha.0.20201126085352-5b6802d00eaf
go: downloading github.com/kataras/iris v0.0.0-20191006184023-c8e73f4f4df2
go: github.com/kataras/iris/v12 master => v12.2.0-alpha.0.20201126085352-5b6802d00eaf
go: downloading github.com/tdewolff/minify/v2 v2.9.10
go: downloading github.com/BurntSushi/toml v0.3.1
go: downloading github.com/kataras/tunnel v0.0.2
go: downloading github.com/mailru/easyjson v0.7.6
go: downloading gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
go: downloading github.com/json-iterator/go v1.1.10
go: downloading github.com/schollz/closestmatch v2.1.0+incompatible
go: downloading github.com/fatih/structs v1.1.0
go: downloading github.com/CloudyKit/jet/v5 v5.1.1
go: downloading github.com/flosch/pongo2/v4 v4.0.0
go: downloading github.com/kataras/golog v0.1.5
go: downloading gopkg.in/ini.v1 v1.62.0
go: downloading golang.org/x/text v0.3.4
go: downloading github.com/kataras/blocks v0.0.4
go: downloading github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421
go: downloading github.com/tdewolff/parse/v2 v2.5.5
go: downloading github.com/kataras/pio v0.0.10
go: downloading github.com/iris-contrib/jade v1.1.4
go: downloading google.golang.org/protobuf v1.25.0
go: downloading github.com/yosssi/ace v0.0.5
go: downloading github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53
go: downloading golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
go: downloading github.com/google/uuid v1.1.2
go: downloading github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible
go: downloading golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
go: downloading github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742
go: downloading golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
go: downloading github.com/russross/blackfriday v1.5.2
go: downloading github.com/klauspost/compress v1.11.3
go: downloading github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385
go: downloading github.com/andybalholm/brotli v1.0.1
go: downloading github.com/vmihailenco/msgpack/v5 v5.0.0
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading github.com/iris-contrib/schema v0.0.6
go: downloading github.com/vmihailenco/tagparser v0.1.2
go: downloading github.com/kataras/sitemap v0.0.5
go: downloading github.com/valyala/bytebufferpool v1.0.0
go: downloading golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392
go: downloading github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398
go: downloading github.com/microcosm-cc/bluemonday v1.0.4
go: downloading github.com/chris-ramon/douceur v0.2.0
go: downloading github.com/aymerick/douceur v0.2.0
go: downloading github.com/gorilla/css v1.0.0

以上安裝在了~/go/pkg/mod目錄下了:

創(chuàng)建一個main.go文件:

%vim main.go
package main
 
import (
 "github.com/kataras/iris/v12"
)
 
func main() {
 app := iris.New()
 app.Get("/", func(ctx iris.Context) {
  ctx.HTML("h1>Hello World!/h1>")
  app.Logger().Info("我在學(xué)習(xí)Iris噢")
 })
 app.Run(iris.Addr(":8009"))
}
 
以上保存后運行:
% go run main.go 
Now listening on: http://localhost:8009
Application started. Press CMD+C to shut down.

用goland打開剛才的iris項目發(fā)現(xiàn)不能識別iris,引入的iris部分提示紅色,解決辦法為:Preferences->Go Modules

保存即可

外部庫下載到項目根目錄下:

 % go mod vendor 

執(zhí)行之后,項目的根目錄下增加了一個vendor的文件夾,文件夾的名字和PHP的composer生成的文件夾相同,作用也是一樣的。

然后在這基礎(chǔ)上可以進行功能的開發(fā)了。

到此這篇關(guān)于mac下安裝golang框架iris的方法的文章就介紹到這了,更多相關(guān)golang框架iris內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • golang常用庫之操作數(shù)據(jù)庫的orm框架-gorm基本使用詳解
  • golang 網(wǎng)絡(luò)框架之gin的使用方法
  • golang日志框架之logrus的使用
  • 詳解Golang Iris框架的基本使用

標(biāo)簽:松原 武漢 保定 河池 宜春 鷹潭 黔西 泰安

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《mac下安裝golang框架iris的方法》,本文關(guān)鍵詞  mac,下,安裝,golang,框架,iris,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《mac下安裝golang框架iris的方法》相關(guān)的同類信息!
  • 本頁收集關(guān)于mac下安裝golang框架iris的方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章