{"id":43231,"date":"2024-12-01T09:43:05","date_gmt":"2024-12-01T01:43:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/43231\/"},"modified":"2024-12-01T09:43:05","modified_gmt":"2024-12-01T01:43:05","slug":"%e6%9c%ac%e5%9c%b0%e8%bf%90%e8%a1%8c-go-tour-%e6%97%b6%e5%87%ba%e9%94%99%ef%bc%9a%e6%89%be%e4%b8%8d%e5%88%b0%e6%b8%b8%e8%a7%88%e6%96%87%e4%bb%b6%ef%bc%9a%e6%89%be%e4%b8%8d%e5%88%b0-go-tour-%e5%86%85","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/43231\/","title":{"rendered":"\u672c\u5730\u8fd0\u884c Go Tour \u65f6\u51fa\u9519\uff1a\u627e\u4e0d\u5230\u6e38\u89c8\u6587\u4ef6\uff1a\u627e\u4e0d\u5230 go-tour \u5185\u5bb9\uff1b\u68c0\u67e5 $GOROOT \u548c $GOPATH"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span> <span>\u672c\u5730\u8fd0\u884c Go Tour \u65f6\u51fa\u9519\uff1a\u627e\u4e0d\u5230\u6e38\u89c8\u6587\u4ef6\uff1a\u627e\u4e0d\u5230 go-tour \u5185\u5bb9\uff1b\u68c0\u67e5 $GOROOT \u548c $GOPATH<\/span><\/p>\n<h1>\u672c\u5730\u8fd0\u884c Go Tour \u65f6\u51fa\u9519\uff1a\u627e\u4e0d\u5230\u6e38\u89c8\u6587\u4ef6\uff1a\u627e\u4e0d\u5230 go-tour \u5185\u5bb9\uff1b\u68c0\u67e5 $GOROOT \u548c $GOPATH<\/h1>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-30 23:30:36<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u73cd\u60dc\u65f6\u95f4\uff0c\u52e4\u594b\u5b66\u4e60\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u672c\u5730\u8fd0\u884c Go Tour \u65f6\u51fa\u9519\uff1a\u627e\u4e0d\u5230\u6e38\u89c8\u6587\u4ef6\uff1a\u627e\u4e0d\u5230 go-tour \u5185\u5bb9\uff1b\u68c0\u67e5 $GOROOT \u548c $GOPATH\u300b<\/span>\uff0c\u6b63\u6587\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\uff0c\u6216\u8005\u662f\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u6709\u7591\u95ee\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u6211\uff01\u540e\u9762\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u5185\u5bb9\u7684\uff0c\u5e0c\u671b\u90fd\u80fd\u5e2e\u5230\u6b63\u5728\u5b66\u4e60\u7684\u5927\u5bb6\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p><code>go \u7248\u672c go1.12.9 darwin\/amd64<\/code><\/p>\n<p>\u5b89\u88c5 <code>golang.org\/x\/tour<\/code> \u8f6f\u4ef6\u5305\u540e\uff0c\u6211\u8fd0\u884c\u547d\u4ee4 <code>tour<\/code> \u5e76\u6536\u5230\u9519\u8bef\uff1a<\/p>\n<pre>couldn't find tour files: could not find go-tour content; check $goroot and $gopath<\/pre>\n<p>\u8fd9\u662f <code>go env<\/code> \u7684\u8f93\u51fa\uff1a<\/p>\n<pre>goarch=\"amd64\"\ngobin=\"\"\ngocache=\"\/users\/elk\/library\/caches\/go-build\"\ngoexe=\"\"\ngoflags=\"\"\ngohostarch=\"amd64\"\ngohostos=\"darwin\"\ngoos=\"darwin\"\ngopath=\"\/users\/elk\/ccode\/go\"\ngoproxy=\"https:\/\/goproxy.io\"\ngorace=\"\"\ngoroot=\"\/usr\/local\/go\"\ngotmpdir=\"\"\ngotooldir=\"\/usr\/local\/go\/pkg\/tool\/darwin_amd64\"\ngccgo=\"gccgo\"\ncc=\"clang\"\ncxx=\"clang++\"\ncgo_enabled=\"1\"\ngomod=\"\/dev\/null\"\ncgo_cflags=\"-g -o2\"\ncgo_cppflags=\"\"\ncgo_cxxflags=\"-g -o2\"\ncgo_fflags=\"-g -o2\"\ncgo_ldflags=\"-g -o2\"\npkg_config=\"pkg-config\"\ngogccflags=\"-fpic -m64 -pthread -fno-caret-diagnostics -qunused-arguments -fmessage-length=0 -fdebug-prefix-map=\/var\/folders\/5d\/q9dj2fxx4t71w0g5g00cvlkh0000gn\/t\/go-build144784202=\/tmp\/go-build -gno-record-gcc-switches -fno-common\"<\/pre>\n<p>\u6211\u5728<code>.zshrc<\/code>\u4e2d\u6dfb\u52a0\u4e24\u884c\uff1a<\/p>\n<pre>export GOPATH=\"$HOME\/ccode\/go\"\nexport PATH=\"$PATH:$GOPATH\/bin\"<\/pre>\n<p>\u547d\u4ee4 <code>go get golang.org\/x\/tour<\/code> \u8fd0\u884c\u65f6\u6ca1\u6709\u9519\u8bef\u3002<\/p>\n<p>\u5947\u602a\u7684\u662f\uff1a <code>echo $goroot<\/code> \u5c06\u663e\u793a\u4e00\u4e2a\u7a7a\u884c \u5e76\u4e14<code>echo $gopath<\/code>\u4e0e<code>go env<\/code>\u4e00\u81f4\u3002<\/p>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p>\u53ef\u80fd\u662f\u4f60\u901a\u8fc7go111module = on\u663e\u5f0f\u542f\u7528go\u6a21\u5757\uff0c\u7136\u540etour\u7684\u4ee3\u7801\u4e0b\u8f7d\u5230\u4e86<code>$gopath\/pkg\/mod\/golang.org\/x\/<\/code>\u76ee\u5f55\u4e0b\uff0c\u4f46\u662ftour\u7a0b\u5e8f\u901a\u8fc7ctx.import\u67e5\u627etour src\u4ee3\u7801\u76ee\u5f55\uff0c\u6b64\u65f6\u53ea\u4f1a\u6765\u81ea<code>$goroot\/src\/golang.org\/x\/tour<\/code>\u6216<code>$gopath\/src\/golang.org\/x\/tour<\/code>\uff0c\u800c\u4e0d\u4f1a\u6765\u81ea<code>$gopath\/pkg\/mod<\/code>\uff0c\u6240\u4ee5\u5bfc\u81f4\u53ef\u4ee5\u627e\u4e0d\u5230\u65c5\u6e38\u6e90\u4ee3\u7801\u76ee\u5f55\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p>\u89e3\u51b3\u65b9\u68481\uff1a\u5c06<code>$gopath\/pkg\/mod\/golang.org\/x\/<\/code>\u590d\u5236\u5230<code>$gopath\/src\/golang.org\/x\/tour<\/code><\/p>\n<p>\u89e3\u51b3\u65b9\u6848\u4e8c\uff1a\u4fee\u6539\u6e38\u89c8\u6e90local.go\u6587\u4ef6<\/p>\n<pre>func findRoot() (string, error) {\n    ...\n\n    if os.Getenv(\"GO111MODULE\") == \"on\" {\n        pkgDir := filepath.Join(os.Getenv(\"GOPATH\"), \"pkg\", \"mod\")\n        cfg := &amp;packages.Config{Mode: packages.LoadFiles, Dir: pkgDir}\n        pkgs, _ := packages.Load(cfg, basePkg)\n        for _, pkg := range pkgs {\n            for _, goFile := range pkg.GoFiles {\n                root := filepath.Dir(goFile)\n                if isRoot(root) {\n                    return root, nil\n                }\n            }\n        }\n    }\n    return \"\", fmt.Errorf(\"could not find go-tour content; check $GOROOT and $GOPATH\")\n}\n<\/pre>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\u7c73\u4e91\uff01\u66f4\u591a\u5173\u4e8eGolang\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &gt; &gt; \u672c\u5730\u8fd0\u884c Go Tour \u65f6\u51fa\u9519\uff1a\u627e\u4e0d\u5230\u6e38\u89c8\u6587\u4ef6\uff1a\u627e\u4e0d\u5230 go-tour \u5185\u5bb9\uff1b\u68c0\u67e5 $GOROOT \u548c $GOPATH \u672c\u5730\u8fd0\u884c Go Tour \u65f6\u51fa\u9519\uff1a\u627e\u4e0d\u5230\u6e38\u89c8\u6587\u4ef6\uff1a\u627e\u4e0d\u5230 go-tour \u5185\u5bb9\uff1b\u68c0\u67e5 $GOROOT \u548c $GOPATH \u6765\u6e90\uff1astackoverflow 2024-04-30 23:30:36 0\u6d4f\u89c8 \u6536\u85cf \u73cd\u60dc\u65f6\u95f4\uff0c\u52e4\u594b\u5b66\u4e60\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u300a\u672c\u5730\u8fd0\u884c Go Tour \u65f6\u51fa\u9519\uff1a\u627e\u4e0d\u5230\u6e38\u89c8\u6587\u4ef6\uff1a\u627e\u4e0d\u5230 go-tour \u5185\u5bb9\uff1b\u68c0\u67e5 $GOROOT \u548c $GOPATH\u300b\uff0c\u6b63\u6587\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230\u7b49\u7b49\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60Golang\uff0c\u6216\u8005\u662f\u5bf9Golang\u6709\u7591\u95ee\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u6211\uff01\u540e\u9762\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u5185\u5bb9\u7684\uff0c\u5e0c\u671b\u90fd\u80fd\u5e2e\u5230\u6b63\u5728\u5b66\u4e60\u7684\u5927\u5bb6\uff01 \u95ee\u9898\u5185\u5bb9 go \u7248\u672c go1.12.9 darwin\/amd64 \u5b89\u88c5 golang.org\/x\/tour \u8f6f\u4ef6\u5305\u540e\uff0c\u6211\u8fd0\u884c\u547d\u4ee4 tour \u5e76\u6536\u5230\u9519\u8bef\uff1a couldn&#8217;t find tour files: could not find go-tour [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-43231","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/43231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=43231"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/43231\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=43231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=43231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=43231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}