接着上一节的内容,在我们的workspace (D:\Gopher) 里面创建子目录 hello,他的绝对路径为:D:\Gopher\src\github.com\tuo\hello

 

创建一个 Hello.go 文件

在 D:\Gopher\src\github.com\tuo\hello 目录下创建一个名字为 hello.go 的文件,内容如下:

 

package main

import "fmt"

func main(){
    fmt.Printf("Hello World!\n")
}

 

 

使用go tool install 源文件

在当前目录下: D:\Gopher\src\github.com\tuo\hello  运行命令:

$ go install

 

我们可以看到在workspace 的子目录 bin 下面生成了一个可执行文件 hello.exe

现在,跳转到bin目录下,运行 hello.exe 得到输出:

Go - 第一个 go 程序 -- helloworld

 

相关文章:

  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2021-08-26
  • 2019-10-18
  • 2021-09-28
  • 2022-12-23
  • 2021-10-15
猜你喜欢
  • 2021-05-04
  • 2022-01-15
  • 2021-06-25
  • 2021-08-22
  • 2021-06-18
  • 2022-01-20
相关资源
相似解决方案