[LINUX] I got an error when trying to run Hello World in Go language

The story that Hello world could not be done

I had the opportunity to use Golang in my business. I didn't touch it in earnest, so I tried to study by myself for the time being.

--For the time being, create hello.go and try to display hello world.

$ go run hello.go
exec: "C:\\Users\\xxxxx\\AppData\\Local\\Temp\\go-build929698758\\b001\\exe\\hello": file does not exist

Ah? ?? what's this? Will you die in hello World? usually? That's why.

Cause of failure

For the time being, just try build

xxxxx@xxx MSYS /c/Users/xxxxx/Documents/test/go
$ go build hello.go

xxxxx@xxx MSYS /c/Users/xxxxx/Documents/test/go
$ ls
hello  hello.go

--Binary? Isn't windows! !!

If you run it on windows

$ ls
hello.exe  hello.go

The correct answer is that you can do it ~

** The cause of this was the environment variable GOOS. ** **

$ env | grep GOOS
GOOS=linux

It was like this. This GOOS = linux didn't work. I didn't want to set it to texto during work. If you set the environment variable GOOS = linux, it seems that the binary file created by build is created for Linux? Can it be run on MSYS2 or git-for-windows? I thought, but it was an error. By the way

What to do

Change GOOS

$ export GOOS=windows
#If it is cmd,
set GOOS=windows

If you build after doing hello.exe will be generated. This is the solution. I don't know if it's correct to set GOOS = windows. Should I delete this environment variable already?

Recommended Posts

I got an error when trying to run Hello World in Go language
I got an error when trying to install Xgboost and its solution
Hello World in GO language
I get an error when trying to install maec 4.0.1.0 with pip
I got an error when I tried to process luigi in parallel on windows, but the solution
I got an error when saving with OpenCV
Error when trying to install psycopg2 in Python
[Python] I want to know the variables in the function when an error occurs!
I got an error when I put opencv in python3 with Raspberry Pi [Remedy]
I get an error when I put opencv in pyautoGUI
I get an error when trying meinheld + WebSocket + mongodb
I got an error when using Tensorboard with Pytorch
Programming language in "Hello World"
I got stuck when trying to specify a relative path with relative_to () in python
I got an error in vim and zsh in Python 3.7 series
I get [Error 2055] when trying to connect to MySQL on Heroku
UnicodeEncodeError when trying to run radon
Post to slack in Go language
I got an AttributeError when mocking the open method in python
I got an error when I ran composer global require laravel / installer
When I get an error with Pylint in Atom on Windows
I got an error when I ran meteor add accounts-password and got hooked
I got an SSL Error when I installed Anaconda in a new environment, so I solved it (Windows10, Anaconda3-2019.10)
When I get an error with PyInstaller
What to do if you get an error when trying to load mnist
I got an unfamiliar error in Django: TypeError: resolve () got an unexpected keyword argument'strict'
How to display Hello world in python
[OSX] [pyenv] What to do when an SSL error occurs in pip
What to do if you get an error when trying to send a message in tasks.loop () immediately after startup
Workaround if you get an error when trying to install PySide with pip
In the Chainer tutorial, I get an error when importing a package. (mock)
[python] What to do when an error occurs in send_keys of headless chrome
An error occurs when trying to import scikit-learn after connecting to Oracle with SQLAlchemy
I referred to it when I got stuck in the django geodjango tutorial (editing)
Hello World with gRPC / go in Docker environment
When I get a chromedriver error in Selenium
Hello world with full features of Go language
I wrote the hexagonal architecture in go language
What to do if you get an error when importing matplotlib in Python (Mac)
I want to get an error message in Japanese with django Password Change Form
I got an error when pip install pandas on Mac, so I dealt with it
I wrote a CLI tool in Go language to view Qiita's tag feed with CLI
I get an error when I try to raise Python to 3 series using pyenv on Catalina
What to do if you run python in IntelliJ and end with an error
What I do when imitating embedded go in python
I got an error that Python couldn't read settings.ini
When I tried to introduce python3 to atom, I got stuck
Stumble when converting bidirectional list to JSON in Go
When you get an error in python scraping (requests)
I was addicted to trying logging.getLogger in Flask 1.1.x
I want to do something in Python when I finish
Go language to see and remember Part 7 C language in GO language
I got an error when pip install tweepy on macOS Sierra, so I dealt with it
Error and solution when trying to run a classifier made with Labellio with my own ubuntu
When I installed python on macOS and used it, I got an error when I put an https connection
When creating a pipenv environment, I got addicted to "Value Error: Not a valid python path"
The story I was addicted to when I specified nil as a function argument in Go
What to do if you get an error when running "certbot renew" in CakePHP environment
When I got a list of study sessions in Python, I found something I wanted to make
What to do if you get an Undefined error when trying to use pip with pyenv
I want to improve efficiency with Python even in an experimental system (4) Use ser.close () when an error is thrown using try syntax