WindowsでGo をHello, worldした

以前、macでHello, worldしたが、

最近いろいろな会社で使われた出したようなので。

思い出しがてら。

 

msiでインストールしたら、ワンクリックなのでとても楽だった。

 

Getting Started - The Go Programming Language

https://golang.org/doc/install?download=go1.11.1.windows-amd64.msi

golang/go: The Go programming language

https://github.com/golang/go

はじめての Go 言語 (on Windows) - Qiita

https://qiita.com/spiegel-im-spiegel/items/dca0df389df1470bdbfa




Microsoft Windows [Version 6.1.7601]

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

 

C:\chino>go

Go is a tool for managing Go source code.

 

Usage:

 

       go <command> [arguments]

 

The commands are:

 

       bug         start a bug report

       build       compile packages and dependencies

       clean       remove object files and cached files

       doc         show documentation for package or symbol

       env         print Go environment information

       fix         update packages to use new APIs

       fmt         gofmt (reformat) package sources

       generate    generate Go files by processing source

       get         download and install packages and dependencies

       install     compile and install packages and dependencies

       list        list packages or modules

       mod         module maintenance

       run         compile and run Go program

       test        test packages

       tool        run specified go tool

       version     print Go version

       vet         report likely mistakes in packages

 

Use "go help <command>" for more information about a command.

 

Additional help topics:

 

       buildmode   build modes

       c           calling between Go and C

       cache       build and test caching

       environment environment variables

       filetype    file types

       go.mod      the go.mod file

       gopath      GOPATH environment variable

       gopath-get  legacy GOPATH go get

       goproxy     module proxy protocol

       importpath  import path syntax

       modules     modules, module versions, and more

       module-get  module-aware go get

       packages    package lists and patterns

       testflag    testing flags

       testfunc    testing functions

 

Use "go help <topic>" for more information about that topic.

 

C:\chino>go version

go version go1.11.1 windows/amd64

 

c:\chino>go run hello.go

hello, world

 

c:\chino>go build hello.go

 

c:\chino>hello.exe

hello, world




  • hello.go

package main

 

import "fmt"

 

func main() {

    fmt.Printf("hello, world\n")

}