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
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@adamijak
Copy link

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 Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Sep 9, 2020
@gopherbot gopherbot added this to the Unreleased milestone Sep 9, 2020
@stamblerre
Copy link
Contributor

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 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants