Go言語学習者です。パッケージとディレクトリの関係がまだよくわかっていません。
今、練習で偶数奇数判定コードのテストコードを書いています。
ディレクトリ構成(ツリー)・ソースコードとvscodeのproblem欄のエラーメッセージを貼ります。
エラーメッセージを読んだ感じ、どう考えてもファイルの置き場所かパッケージの設定が違うのですが、どう直すべきかわかりません。
console
1pwd 2 > /Users/〇〇/Desktop/go 3tree 4 > . 5 ├── oddends.go 6 └── oddends_test 7 └── oddends_test.go
- oddends.go
go
1package oddends 2 3func oes(x int) bool { 4 if x%2 == 0 { 5 return true 6 } else { 7 return false 8 } 9} 10
- oddends_test.go
go
1package oddends_test 2 3import "testing" 4 5var testcases = []struct { 6 in int 7 out bool 8}{ 9 {0, true}, {1, false}, {2, true}, {100, true}, {222222, true}, 10} 11 12func Testoddends(t *testing.T) { 13 for _, tt := range testcases { 14 s := oddends.oes(tt.in) 15 if s != tt.out { 16 t.Errorf("oes(%d) => required: %t ,result: %t", tt.in, tt.out, s) 17 } 18 } 19} 20
- 番号リストエラー
English
1oddends_test.go 2 undefined: oddends go [14、 8]

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/10/14 11:22
2020/10/14 23:30
2020/10/15 08:04