日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

实习第一周(Golang)

發布時間:2025/3/19 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 实习第一周(Golang) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄

    • 一,序
    • 二,基礎學習
    • 三,環境安裝
    • 四,項目操練
      • GO111MODULE
    • 五,此外附上我用過的一些資料

一,序

2020年8月3我來實習了,試想一個Java都還沒學會熟練使用的人,卻要用golang去重新做項目,我能退縮嗎,當然不能,于是我用一周的時間來熟悉golang,

二,基礎學習

于是我對基礎的數據類型,指針,運算符,程序流程控制,函數,包,錯誤處理,數組,切片,map,結構體,方法,封裝繼承接口

以及多態,文件操作,以及JSON序列化反序列化,單元測試,進程,線程,反射,管道,socket編程,redis,等有了初步了解,是不是現在就成功了,腫么可能,我要立馬上線,去拿項目讀源碼學習,于是開始了我的配置環境階段

三,環境安裝

我安裝的是最新的go版本1.14,下載的是go1.14.windows-amd64.msi 安裝文件。文件需要到https://golang.org/ 去下載。由于眾所周知的原因,需要翻墻,否則網站打不開。

安裝很順利。安裝完后打開一個cmd窗口,輸入:

E:\goproject>go version go version go1.14.6 windows/amd64

說明已經安裝成功。

四,項目操練

想著到github上找一個go語言編寫的項目弄到本地查看編譯下。找到一個bee,beego在如何獲取地方看到:

go get github.com/astaxie/beego

這是要在cmd 窗口直接輸入這行命令就能獲取。我于是試了下。可是,輸入命令后看著是在運行,但是運行結束后,報以下提示信息,

原來是代理的問題,

unrecognized import path "golang.org/x/text/transform": https fetch: Get "https://golang.org/x/text/transform?go-get=1":dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. unrecognized import path "golang.org/x/text/unicode/norm": https fetch: Get "https://golang.org/x/text/unicode/norm?go-g et=1": dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly re spond after a period of time, or established connection failed because connected host has failed to respond. # cd .; git clone -- https://github.com/gadelkareem/delve C:\Users\luckly\go\src\github.com\gadelkareem\delve Cloning into 'C:\Users\luckly\go\src\github.com\gadelkareem\delve'... error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 fatal: the remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed package github.com/gadelkareem/delve/pkg/terminal: exit status 128 package github.com/gadelkareem/delve/service: cannot find package "github.com/gadelkareem/delve/service" in any of:F:\sofaware\GO\src\github.com\gadelkareem\delve\service (from $GOROOT)C:\Users\luckly\go\src\github.com\gadelkareem\delve\service (from $GOPATH) package github.com/gadelkareem/delve/service/debugger: cannot find package "github.com/gadelkareem/delve/service/debugger" in any of:F:\sofaware\GO\src\github.com\gadelkareem\delve\service\debugger (from $GOROOT)C:\Users\luckly\go\src\github.com\gadelkareem\delve\service\debugger (from $GOPATH) package github.com/gadelkareem/delve/service/rpc2: cannot find package "github.com/gadelkareem/delve/service/rpc2" in any of:F:\sofaware\GO\src\github.com\gadelkareem\delve\service\rpc2 (from $GOROOT)C:\Users\luckly\go\src\github.com\gadelkareem\delve\service\rpc2 (from $GOPATH) package github.com/gadelkareem/delve/service/rpccommon: cannot find package "github.com/gadelkareem/delve/service/rpccommon" in any of:F:\sofaware\GO\src\github.com\gadelkareem\delve\service\rpccommon (from $GOROOT)C:\Users\luckly\go\src\github.com\gadelkareem\delve\service\rpccommon (from $GOPATH) # cd C:\Users\luckly\go\src\github.com\astaxie\beego; git pull --ff-only fatal: not a git repository (or any parent up to mount point /cygdrive) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). package github.com/astaxie/beego/swagger: exit status 128 package github.com/astaxie/beego/utils: cannot find package "github.com/astaxie/beego/utils" in any of:F:\sofaware\GO\src\github.com\astaxie\beego\utils (from $GOROOT)C:\Users\luckly\go\src\github.com\astaxie\beego\utils (from $GOPATH)

于是我發揮了愛學習,愛搜索,愛詢問的能力,了解到了有代理這回事,使用go.mod來進行包管理

GO111MODULE

GO111MODULE有三個值:off, on和auto(默認值)。

  • GO111MODULE=off,go命令行將不會支持module功能,尋找依賴包的方式將會沿用舊版本那種通過vendor目錄或者GOPATH模式來查找。

  • GO111MODULE=on,go命令行會使用modules,而一點也不會去GOPATH目錄下查找。

  • GO111MODULE=auto

    ,默認值,go命令行將會根據當前目錄來決定是否啟用module功能。這種情況下可以分為兩種情形:

    • 當前目錄在GOPATH/src之外且該目錄包含go.mod文件
    • 當前文件在包含go.mod文件的目錄下面。

那么我們就來設置吧,我打開命令行:

C:\Users\luckly>go env -w GO111MODULE=onC:\Users\luckly>go env -w GOPROXY=https://goproxy.io,direct

并進行了簡單測試,新建一個名為 main.go的項目,項目路徑 e:\goproject (注意,該路徑并不在GOPATH里)

當我再次打開命令行的時候

C:\Users\luckly>go get github.com/beego/bee go: downloading github.com/beego/bee v1.12.0 go: github.com/beego/bee upgrade => v1.12.0 go: downloading github.com/gorilla/websocket v1.4.2 go: downloading github.com/astaxie/beego v1.12.1 go: downloading github.com/lib/pq v1.7.0 go: downloading github.com/go-sql-driver/mysql v1.5.0 go: downloading github.com/gadelkareem/delve v1.4.2-0.20200619175259-dcd0133 go: downloading github.com/smartwalle/pongo2render v1.0.1 go: downloading gopkg.in/yaml.v2 v2.3.0 go: downloading github.com/pelletier/go-toml v1.2.0 go: downloading github.com/davecgh/go-spew v1.1.1 go: downloading github.com/fsnotify/fsnotify v1.4.9 go: downloading github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915 go: downloading golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 go: downloading github.com/spf13/viper v1.7.0 go: downloading github.com/hashicorp/hcl v1.0.0 go: downloading github.com/spf13/pflag v1.0.3 go: downloading github.com/mitchellh/mapstructure v1.1.2 go: downloading github.com/spf13/jwalterweatherman v1.0.0 go: downloading gopkg.in/ini.v1 v1.51.0 go: downloading github.com/spf13/cast v1.3.0 go: downloading github.com/magiconair/properties v1.8.1 go: downloading github.com/subosito/gotenv v1.2.0 go: downloading github.com/spf13/afero v1.1.2 go: downloading golang.org/x/text v0.3.2 go: downloading github.com/sirupsen/logrus v1.6.0 go: downloading github.com/mattn/go-colorable v0.0.9 go: downloading github.com/cosiner/argv v0.1.0 go: downloading github.com/mattn/go-isatty v0.0.3 go: downloading golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 go: downloading github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b go: downloading github.com/hashicorp/golang-lru v0.5.4 go: downloading go.starlark.net v0.0.0-20190702223751-32f345186213 go: downloading github.com/konsorten/go-windows-terminal-sequences v1.0.3

竟然成功了,

于是我又緊追其后,在命令行輸入了

C:\Users\luckly>bee Bee is a Fast and Flexible tool for managing your Beego Web Application.USAGEbee command [arguments]AVAILABLE COMMANDSversion Prints the current Bee versionmigrate Runs database migrationsapi Creates a Beego API applicationbale Transforms non-Go files to Go source filesfix Fixes your application by making it compatible with newer versions of Beegopro Source code generatordlv Start a debugging session using Delvedockerize Generates a Dockerfile for your Beego applicationgenerate Source code generatorhprose Creates an RPC application based on Hprose and Beego frameworksnew Creates a Beego applicationpack Compresses a Beego application into a single filers Run customized scriptsrun Run the application by starting a local development serverserver serving static content over HTTP on portUse bee help [command] for more information about a command.ADDITIONAL HELP TOPICSUse bee help [topic] for more information about that topic.

又成功了,至次就成功了嗎?沒有,為啥?

bee下載到那兒了,不知道,罪過罪過,在我的go語言安裝目錄的,src ,pkg等下面都沒找到,這難道沒安上?還是哪里有問題。各種查找。最后終于找到一個解決辦法。需要自己創建一個工作區目錄。為什么不使用安裝目錄,是因為要保證安裝目錄的純潔性。

打開一看,咋跑C盤去了,仔細一看是自己把代碼敲錯了,自動添加到C盤了,

我在F盤創建了一個工作目錄:F:\software\GO,目錄必須是英文,不能有漢字。在這個目錄中還要創建3個目錄。分別是src,pkg,bin三個目錄。并且要在windows系統變量中增加GOPATH,值設置為:F:\software\GO。終于改過來了

然后再打開一個cmd窗口,輸入:

go get github.com/beego/bee

執行成功后,可以看到在工作區的src目錄下已經有了相應的項目文件。在github.com目錄下。

五,此外附上我用過的一些資料

尚硅谷韓順平Go語言核心編程

redis

一些項目

學習腦圖

一些資源

激活goland

Git手冊

Golang標準庫文檔

go學習文檔

可以考慮 http://tour.studygolang.com 以及 http://books.studygolang.com/gobyexample/

https://www.json.cn/#

https://www.oschina.net/search?scope=project&q=golang

1.開源項目總結

開源項目

docker

golang

kubernetes

etcd

beego

martini

codis

delve

GO web

beego

GO語框架gin中文中檔

以上是我上周的進展,下周繼續努力

i)

codis

delve

GO web

beego

GO語框架gin中文中檔

以上是我上周的進展,下周繼續努力

總結

以上是生活随笔為你收集整理的实习第一周(Golang)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。