杩愯绋嬪簭鏃舵姤go: cannot find main module, but found .git/config in

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了杩愯绋嬪簭鏃舵姤go: cannot find main module, but found .git/config in相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/ati' title='ati'>ati   off   娌℃湁   ase   wrong   pre   creating   find   config   

缂栧啓鍗曞厓娴嬭瘯锛岃繍琛屾椂鎶ヤ笅闈㈢殑閿欒

haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/base/cheshi01$ go test
go: cannot find main module, but found .git/config in /media/haima/34E401CC64DD0E28/site/go/src/haimait/learn
        to create a module there, run:
        cd ../.. && go mod init

鍑洪敊鍘熷洜鏄紑鍚簡go mod锛屼絾鏄病鏈夊垵浣垮寲鐢熸垚go.mod鏂囦欢

瑙e喅鏂规硶涓€锛?/p>

鍏抽棴gomod

haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/base/cheshi01$ export GO111MODULE=off
haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/base/cheshi01$ go env
GO111MODULE="off"
鈥︹€?#鐪佺暐

haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/base/cheshi01$ go test
--- FAIL: TestAdd2 (0.00s)
    cheshi01_test.go:16: result is wrong!
FAIL
exit status 1
FAIL    haimait/learn/base/cheshi01     0.002s

瑙e喅鏂规硶浜?/p>

haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/base/cheshi01$ go mod init
go: creating new go.mod: module haimait/learn/base/cheshi01
haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/base/cheshi01$ go mod tidy
haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/base/cheshi01$ go test
--- FAIL: TestAdd2 (0.00s)
    cheshi01_test.go:16: result is wrong!
FAIL
exit status 1
FAIL    haimait/learn/base/cheshi01     0.002s
haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/base/cheshi01$ go test -v
=== RUN   TestAdd1
    TestAdd1: cheshi01_test.go:11: result is right!
--- PASS: TestAdd1 (0.00s)
=== RUN   TestAdd2
    TestAdd2: cheshi01_test.go:16: result is wrong!
--- FAIL: TestAdd2 (0.00s)
FAIL
exit status 1
FAIL    haimait/learn/base/cheshi01     0.002s

以上是关于杩愯绋嬪簭鏃舵姤go: cannot find main module, but found .git/config in的主要内容,如果未能解决你的问题,请参考以下文章

绋嬪簭娴嬭瘯

Anaconda涓畨瑁呬簡Libtiff妯″潡锛屼絾杩愯绋嬪簭鏄剧ずModuleNotFoundError: No module named 'libtiff'

銆愯绋嬭璁★綔C++銆慍++绋嬪簭璁捐鍩虹锛氱煩闃佃繍绠楀櫒

绋嬪簭鐨勬満鍣ㄧ骇琛ㄧず

灏忕▼搴忎簯鍑芥暟璋冪敤webservice鎺ュ彛

闈㈣瘯蹇呴棶鐨?JVM 杩愯鏃舵暟鎹尯锛屼綘鎳備簡鍚楋紵