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

x/tools/gopls: working with TinyGo #41290

Closed
adamijak opened this issue Sep 9, 2020 · 2 comments
Closed

x/tools/gopls: working with TinyGo #41290

adamijak opened this issue Sep 9, 2020 · 2 comments
Labels

Comments

@adamijak
Copy link

@adamijak adamijak commented Sep 9, 2020

package main
import "machine"
import "time"

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

Setting GOPATH="/path/to/go:/usr/lib/tinygo/src" allows me to include machine.
But still I get error Led not declared in package machine. That's caused by first line of board_bluepill.go is set to // +build bluepill. Its not detected as "machine package".

Any syggestions how to fix this to get gopls working with tinygo.

@gopherbot gopherbot added this to the Unreleased milestone Sep 9, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Sep 9, 2020

You will need to add the following to your configuration:

"gopls": {
    "env": {
        "GOFLAGS": "-tags=bluepill"
    }
}
@stamblerre stamblerre removed this from the Unreleased milestone Sep 9, 2020
@stamblerre stamblerre changed the title x/tools/gopls: Tinygo + gopls doesn't work x/tools/gopls: working with TinyGo Sep 9, 2020
@adamijak
Copy link
Author

@adamijak adamijak commented Sep 9, 2020

Thanks to @stamblerre. That worked perfectly.
###SOLUTION###
export GOPATH="/path/to/go:/path/to/tinygo" in my case /usr/lib/tinygo
Create touch .vim/coc-settings.json in your local tinygo project repository.
Put this code in .vim/coc-setings.json

{
        "go.goplsEnv": {
                "GOFLAGS": "-tags=bluepill"
        }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.