Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code Support #1114

Closed
seanaye opened this issue May 16, 2020 · 4 comments
Closed

VS Code Support #1114

seanaye opened this issue May 16, 2020 · 4 comments

Comments

@seanaye
Copy link

seanaye commented May 16, 2020

similar to #465

I'm just getting started with go and am having trouble integrating with VS Code.

I'm on mac and have installed tinygo via homebrew.

According to docs I can run

export GOPATH=$GOPATH:/usr/local/Cellar/tinygo/0.13.1/libexec/tinygo

This however does nothing for vscode import errors.

cannot find package "machine" in any of:
	/usr/local/Cellar/go/1.14.2_1/libexec/src/machine (from $GOROOT)
	~/go/src/machine

I'm assuming I need to symlink /usr/local/Cellar/tinygo/0.13.1/libexec/tinygo into ~/go/src/machine

Does anyone know how to fix these errors in vscode? What is the recommended approach? As I said i'm inexperienced with golang,

@aykevl
Copy link
Member

aykevl commented May 16, 2020

It appears that the GOPATH wasn't picked up VS Code. Remeber that export only works in the current shell, it is not system-wide. You might need to change some settings in VS Code itself to get this to work.

This may be helpful: https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension

@seanaye
Copy link
Author

seanaye commented May 16, 2020

@aykevl Thanks for quick reply

I have added tinygo to my .bash_profile

export GOPATH=$GOPATH:/usr/local/Cellar/tinygo/0.13.1/libexec/tinygo

go env GOPATH
returns
/usr/local/Cellar/tinygo/0.13.1/libexec/tinygo

after closing and restarting vscode Go: Current GOPATH now returns the above path.

This works but is it the recommended way of writing code in go?

Is there a way to get type hints for my specific board? its the Arduino nano 33 IoT

looking at sample code

package main

import (
	"machine"
	"time"
)

func main() {
	led := machine.LED
	led.Configure(machine.PinConfig{Mode: machine.PinOutput})
	for {
		led.Low()
		time.Sleep(time.Millisecond * 500)

		led.High()
		time.Sleep(time.Millisecond * 500)
	}
}

I get type hints for machine.PinConfig but not for machine.LED

@aykevl
Copy link
Member

aykevl commented May 16, 2020

This works but is it the recommended way of writing code in go?

Is there a way to get type hints for my specific board? its the Arduino nano 33 IoT

You will also need to configure build tags. I think you can use go.buildTags for that. To get the list of build tags, run:

tinygo info arduino-nano33

I know this is a bit involved. I'm hoping that we can properly fix this in the future (#941 is a part of that). Until then, this should work.

@seanaye
Copy link
Author

seanaye commented May 17, 2020

Great thanks for all your help. I'm excited to write some Go!

@seanaye seanaye closed this as completed May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants