error while importing time: package sync/atomic is not in std
I recieve the error while importing time: package sync/atomic is not in std error on running the below command:
tinygo flash -target pico main.go
my code is:
package main
import (
"machine"
"time"
)
func main() {
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
for {
led.High()
time.Sleep(time.Second)
led.Low()
time.Sleep(time.Second)
}
}
the version of tinygo and Golang I use:
tinygo version 0.30.0 darwin/amd64 (using go version go1.21.2 and LLVM version 16.0.1)
go version go1.21.2 darwin/arm64
I have the same issue, with the following command:
tinygo build -target=d1mini .
I use these versions:
tinygo version 0.30.0 windows/amd64 (using go version go1.21.5 and LLVM version 16.0.1)
go version go1.21.5 windows/amd64
I tried various go version and it breaks from go 1.21.3 and up, which is a bit weird because AFAIK this release only contains a fix for a CVE (see https://github.com/golang/go/issues?q=milestone%3AGo1.21.3+label%3ACherryPickApproved). And this is also weird because this is working with go 1.21.2 (which is the problematic version for @mahdi-khanzadi).
@mahdi-khanzadi maybe you could for now try to downgrade your go version if possible.
I've hit the same issue while trying to setup IDE integration.
Basically I was setting GOROOT to what tinygo info was showing by exporting it.
This causes issues with tinygo finding the real goroot.
Best is to set GOROOT to the cached one for the editor ie GOROOT="*your cached goroot from tinygo info*" vim main.go