Java programmer tried to touch Go language (for the time being)

image

My name is keita69sawada.

Since it seems that I will make a command line tool, I investigated the development language from the following viewpoints.

Go language (golang) looks good! !!

Then, "Would you like to try something in Go language for the time being!" This article was uni-uni.

Target audience

Prerequisites

procedure

1. Prepare the development environment

1-1. Install chocolately (Windows package manager)

See here https://qiita.com/keita69sawada/items/5b7af117a313aae02399

1-2. Install GO language and editor (Visual Studio Code)

Copy and paste the following on the command line to install it.

command


choco install -y golang
choco install -y VisualStudioCode

2. Let's create Hello World in Go language

2-1. Creating a project (working directory)

Copy and paste to the command line.

command


mkdir c:\tmp\project\bin
mkdir c:\tmp\project\src\main
mkdir c:\tmp\project\pkg

The Go language project (directory) structure is as follows.

project(directory)Constitution


 C:\tmp\project
        ├─bin
        ├─pkg
        └─src
            └─main

2-2. Setting the environment variable GOPATH

Set the starting path GOPATH.

set GOPATH=C:\tmp\project

2-3. Implementation (copy and paste)

In the editor (Visual Studio Code), go to % GOPATH% \ src \ main \ hello.go Copy the sauce.

src


package main

import "fmt"

func main() {
	fmt.Println("Hello,world")
}

2-4. Compile and create an .exe file

command


go build -o %GOPATH%\bin\hello.exe %GOPATH%\src\main\hello.go

The exe file is created.

result


C:\tmp\project
├─bin
│      hello.exe
├─pkg
│  └─windows_amd64
│          hello.a
└─src
    └─main
         hello.go

2-5. Try running hello.exe

command


%GOPATH%\bin\hello.exe

I think it will move quickly. 8f07d95d-8145-4a11-9800-9587330b79fe.gif

Summary

This time, it's "touch it for the time being", so it ends with the experience of "The .exe file was created after building! Oh, it worked!". Next, I plan to find time to try out the functions of external command calls and API calls.

Reference URL

Recommended Posts

Java programmer tried to touch Go language (for the time being)
Flow memo to move LOCUST for the time being
Molecular dynamics simulation to try for the time being
Next to Excel, for the time being, jupyter notebook
I want to move selenium for the time being [for mac]
I tried running PIFuHD on Windows for the time being
I tried to illustrate the time and time in C language
[Introduction to Reinforcement Learning] Reinforcement learning to try moving for the time being
I want to create a Dockerfile for the time being.
Let's touch on the Go language
[For self-learning] Go2 for the first time
Let's touch Google's Vision API from Python for the time being
For the time being, I want to convert files with ffmpeg !!
I tried tensorflow for the first time
Python Master RTA for the time being
I tried to touch the COTOHA API
What Java users thought of using the Go language for a day
I tried using scrapy for the first time
How to use MkDocs for the first time
Java programmer touched Go language (Implement Java inheritance in Go language)
For the time being, import them into jupyter
Make a histogram for the time being (matplotlib)
Use logger with Python for the time being
Run yolov4 "for the time being" on windows
I played with Floydhub for the time being
I tried to touch the API of ebay
I tried python programming for the first time.
Try using LINE Notify for the time being
I tried Mind Meld for the first time
virtualenv For the time being, this is all!
Try posting to Qiita for the first time
Try adding an external module to pepper. For the time being, in requests.
I thought I could make a nice gitignore editor, so I tried to make something like MVP for the time being
I will try to summarize the links that seem to be useful for the time being
Run with CentOS7 + Apache2.4 + Python3.6 for the time being
I tried to touch the CSV file with Python
I tried python on heroku for the first time
I will install Arch Linux for the time being.
AI Gaming I tried it for the first time
I tried to identify the language using CNN + Melspectogram
I want to use the Ubuntu desktop environment on Android for the time being (Termux version)
I want to use Ubuntu's desktop environment on Android for the time being (UserLAnd version)
I tried porting the code written for TensorFlow to Theano
[Go language] How to get terminal input in real time
I tried to display the time and today's weather w
I tried to enumerate the differences between java and python
I tried the Google Cloud Vision API for the first time
For the time being, try using the docomo chat dialogue API
Kaggle for the first time (kaggle ①)
Kaguru for the first time
I tried to touch jupyter
I tried to create serverless batch processing for the first time with DynamoDB and Step Functions
I made a function to check if the webhook is received in Lambda for the time being
I tried to describe the traffic in real time with WebSocket
Understanding the python class Struggle (1) Let's move it for the time being
Challenge image classification by TensorFlow2 + Keras 1-Move for the time being-
I tried to display the video playback time (OpenCV: Python version)
Try using FireBase Cloud Firestore in Python for the time being
[Hi Py (Part 1)] I want to make something for the time being, so first set a goal.
I want to use Ubuntu's desktop environment on Android for the time being (Termux version-Japanese input in desktop environment)
For the time being using FastAPI, I want to display how to use API like that on swagger