Set up TinyGo development environment for VS Code

TinyGo's development environment setup for VS Code was a little troublesome, so I wrote it down. The official article is here. Please refer to other articles for installation and setup of TinyGo. Author's environment: MacBook Air (Retina, 13-inch, 2020) macOS Catalina 10.15.5

image.png

2020/09/27 Addendum 1

It was pointed out that .vscode / settings.json is automatically generated when you install and set up the TinyGo extension below. So you can skip the Creations.json Creation part below.

~~ Check TinyGo settings ~~

~~ TinyGo seems to use GOROOT (?) In a different path from the original Go. [^ 1] ~~ As pointed out by @ sago35, TinyGo solves TinyGo dedicated packages such as machine package from TinyGo's ROOT, and other import paths use normal Go language (GOPATH is also the original Go) (Same as). Thank you sago35! Check the GOROOT path for TinyGo at ~~ tinygo info. ~~

$ tinygo info microbit
//Output result...

// LLVM triple:       armv6m-none-eabi
// GOOS:              linux
// GOARCH:            arm
// build tags:        cortexm baremetal linux arm nrf51822 nrf51 nrf microbit tinygo gc.conservative scheduler.tasks
// garbage collector: conservative
// scheduler:         tasks
// cached GOROOT:     /home/user/.cache/tinygo/goroot-go1.14-f930d5b5f36579e8cbd1c139012b3d702281417fb6bdf67303c4697195b9ef1f-syscall

~~ cached GOROOT: ... The path of the line starting with is GOROOT for TinyGo. ~~ Lines starting with ~~ build tags: ... are options to use at build time. ~~

~~ Creating settings.json ~~

~~ You can mess with VSCode settings directly, but I don't want to affect normal Go development, so create a .vscode folder in the project folder and create a settings.json file. Create a. At that time, it is okay to paste GOROOT as it is, but GOFLAGS prefixes it with -tags sequentially and separates it with a comma (`,`) instead of a space. For example, in my environment, the result was build tags: darwin amd64 tinygo gc.extalloc scheduler.coroutines. -tags = darwin, amd64, tinygo, gc.extalloc, scheduler.coroutines``. ~~

settings.json


{
    "go.toolsEnvVars": {
        "GOROOT": "GOROOT that I got earlier...",
        "GOFLAGS": "-tags=avr,baremetal,linux,arm,atmega328p,atmega,avr5,arduino,tinygo,gc.conservative,scheduler.none"
    }
}

Install TinyGo extension

Install TinyGo from Extensions. image.png

After installation, select Tiny Go target from the command palette and select the microcomputer you are using.

image.png

In the case of the author, select ʻarduino` because it is an Arduino compatible machine Maruduino. [^ 2]

image.png

After making your selection, reload VS Code and if the "machine" package auto-completion works correctly, you're done. image.png

[^ 1]: It seems that GOROOT or GOPATH is replaced with a unique one at the time of build (?), But I don't know the details ... I would appreciate it if anyone could teach me in the comments. [^ 2]: I was kind to myself as a beginner of microcomputers, and I was able to get along with choosing Arduino. Thank you marutsu ...!

Recommended Posts

Set up TinyGo development environment for VS Code
Set up a Python development environment with Visual Studio Code
Set up a Python development environment on Marvericks
Set up an Objective-C 2.0 development environment on Linux
Set up a Python development environment with Sublime Text 2
Development environment suitable for ArcPy
Set Up for Mac (Python)
Create a VS Code + Docker development environment on a Linux VM
UpNext2 Development Record # 1 Build Python CI environment in VS Code
[For beginners] Django -Development environment construction-
Integrated Development Environment (IDE) vs. Virtual environment
Emacs settings for Python development environment
Create a Python environment for professionals in VS Code on Windows
Create a simple Python development environment with VS Code and Docker
How to set up the development environment of ev3dev [Windows version]
Prepare a Python virtual environment for your project with venv with VS Code
Python development environment for macOS using venv 2016
(For myself) Put Flask in VS Code
Set up Pipenv in Pycharm in Windows environment
Prepare the development environment for keyhac for Mac
Construction of development environment for Choreonoid class
Building a Python development environment for AI development
Creating a development environment for machine learning
Cross-compiling Raspberry Pi and building a remote debugging development environment with VS Code
Python local development environment construction template [Flask / Django / Jupyter with Docker + VS Code]
Introduce VS Code and Remote Development to an offline environment to make linux development comfortable
VS Code + Azure Functions + Python environment construction procedure
Build Python development environment with Visual Studio Code
Python (Windows 10) Virtual Environment / Package with VS Code
I created a Dockerfile for Django's development environment
Set up python Tornado environment on raspbian jessie
Build a Kubernetes environment for development on Ubuntu
How to set up a local development server
Use Python in Anaconda environment with VS Code
Use Docker development container conveniently with VS Code
Build a mruby development environment for ESP32 (Linux)
Make your Python environment "easy" with VS Code
Build a python execution environment with VS Code
VS Code settings
[Django] Use VS Code + Remote Containers to quickly build a Django container (Docker) development environment.
Environment construction for those who want to study python easily with VS Code (for Mac)
How to set the development environment for each project with VSCode + Python extension + Miniconda
How to set up a Python environment using pyenv
Build a local development environment for Laravel6.X on Mac
Allow real-time code checking in Python development with VS Code
VS Code settings for developing in Python with completion
Tips for speeding up python code correctly with numba
Python development environment with Windows + Anaconda3 + Visual Studio Code
Personal best practices for VS Code-fronted Python development environments
How to set up and compile your Cython environment
Enable intellisense for external libraries with Pipenv + VS Code
Expose settings.json for efficient Python coding in VS Code
Remote debug Django environment created with docker-compose with VS Code
python memo (for myself): About the development environment virtualenv
Cross development environment (developing programs for windows on linux)
[No venv required] The strongest Python development environment created with Remote Containers [VS Code / Docker]
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
I want to set up a GUI development environment with Python or Golang on Mac