亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

去測試錯誤 - 沒有測試文件 - GOPATH中的錯誤

去測試錯誤 - 沒有測試文件 - GOPATH中的錯誤

Go
富國滬深 2022-06-13 17:38:43
在以下環境中:code$ pwd/home/user1/codecode$ echo $GOPATH/home/user1/golib:/home/user1/codecode$ lsbin  pkg  src code$ ls src/github.com/myhub/codingtest/main.go  test_main.gocode$ code$ code$ code$ code$ code$ cat src/github.com/myhub/codingtest/test_main.go package mainimport "testing"func TestSplit(t *testing.T) {        gotAllButLast, gotLast := split(2013)        wantAllButLast := 201        wantLast := 3        if gotAllButLast != wantAllButLast {                t.Errorf("got %d but expected %d", gotAllButLast, wantAllButLast)        }        if wantLast != gotLast {                t.Errorf("got %d but expected %d", gotLast, wantLast)        }}code$ code$ code$ code$ code$ code$ cat src/github.com/myhub/codingtest/main.go package main// Spit n into all but its last digit and its last digitfunc split(n int) (int, int) {        return n / 10, n % 10}func main() {}code$ go test給出以下錯誤:code$ go test github.com/myhub/codingtest?       github.com/myhub/codingtest   [no test files]code$ code$ code$ code$ code$ code$ 如何解決no test files error?
查看完整描述

1 回答

?
當年話下

TA貢獻1890條經驗 獲得超9個贊

要解決您的錯誤,您需要將 test_main.go 重命名為 main_test.go

正如您在文檔中看到的

要編寫新的測試套件,請創建一個名稱以 _test.go 結尾的文件


查看完整回答
反對 回復 2022-06-13
  • 1 回答
  • 0 關注
  • 184 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號