コード
main.go
1 2 3 4 5 |
<span class="k">package</span> <span class="n">main</span> <span class="k">func</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">test</span><span class="p">()</span> <span class="p">}</span> |
test.go
1 2 3 4 5 6 7 |
<span class="k">package</span> <span class="n">main</span> <span class="k">import</span> <span class="s">"fmt"</span> <span class="k">func</span> <span class="n">test</span><span class="p">()</span> <span class="p">{</span> <span class="n">fmt</span><span class="o">.</span><span class="n">Printf</span><span class="p">(</span><span class="s">"%s"</span><span class="p">,</span><span class="s">"Hello"</span><span class="p">)</span> <span class="p">}</span> |
実行
main.go
を指定するとエラーというか、test関数を読み込めないでいる
1 2 3 |
yuta:~/func $ go run main.go # command-line-arguments ./main.go:4:2: undefined: test |
正しい実行
*
で実行しよう!
1 2 |
yuta:~/func $ go run *.go Hello |