Go初心者です。
すごく初歩的なミスな気がして恐縮ですが、
お力添え頂けますと幸いでございます。
下記のようなディレクトリ構造で、
main.goからcal.go内にあるfunc sum()を使おうとしているのですが、
myproject ├── bin ├── pkg └── src └── cal | └── cal.go └── main └── main.go
下記のようなエラーがでております。
error
1src/main/main.go:9: cannot refer to unexported name cal.sum 2src/main/main.go:9: undefined: cal.sum
cal.sumって書き方がおかしいのでしょうか…??
main.goとcal.goのソースコードは下記で、GOPATHは /myprojectのディレクトリに設定してます。
go
1//main.go 2package main 3 4import ( 5 "fmt" 6 "cal" 7) 8 9func main() { 10 var n int = cal.sum(1,2) 11 fmt.Println(n) 12}
go
1//cal.go 2package cal 3 4import( 5 6) 7 8func sum(i, j int) int { 9 return i + j 10}
どなたかご教示頂ければ幸いです。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/11/23 03:24
2015/11/23 03:26
2015/11/23 03:26
2015/11/26 04:25