zoukankan      html  css  js  c++  java
  • 学习Go语言(一)环境安装及HelloWorld

    自己开发的时候,一般用Java和C#居多,偶尔也用Python做点东东。

    想体验一下比较“现代”语言,思来想去就来体验一下Go语言。

    闲话少叙,言归正传,首先就是环境安装,这个轻车熟路:

    (1)到官网下载安装包,本人用Windows平台开发,下载“go1.13.5.windows-amd64.msi”,然后Step by Step安装就Ok了。

        关于环境变量:官网上面要求将安装目录下的bin加到环境变量PATH中,我这里没有加也是可以用的(实践出真知)。

    (2)HelloWord例子:

    在开发环境中新建一个文件夹hello:

    D:dev_repo_go>mkdir hello

    D:dev_repo_go>cd hello

    然后新建一个文件hello.go,内容如下:

    package main
    import "fmt"
    func main() {
        fmt.Printf("Hello, World
    ")
    }
    编译:
    D:dev_repo_gohello>go build
    运行:

    D:dev_repo_gohello>hello.exe
    Hello, World

    (3)第一印象

        和java一样有package,可以import进来;

        每一行的末尾没有分号

        和java的HelloWorld比起来,不需要Class,而且简洁不少;

    (4)不编译直接运行go程序

        go run XXX.go

    所有文章,坚持原创。如有转载,敬请标注出处。
  • 相关阅读:
    Study Plan The Twelfth Day
    Study Plan The Fifteenth Day
    Study Plan The Seventeenth Day
    Study Plan The Tenth Day
    Study Plan The Eighth Day
    Study Plan The Eleventh Day
    Study Plan The Sixteenth Day
    Study Plan The Thirteenth Day
    Study Plan The Fourteenth Day
    Study Plan The Ninth Day
  • 原文地址:https://www.cnblogs.com/siweihz/p/12063923.html
Copyright © 2011-2022 走看看