compiler: implement custom logic for go1.15

For some reason `foo.go` is interpreted as an http URL, and even if we
replace it with `./foo.go` there is an errors with file missing on disk.
Because `CompileWithOptions` should be able to compile file under any
circumstances, we allocate temporary directory base on version used to
compile a binary.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2022-01-21 16:47:22 +03:00
parent cae5b8541d
commit ad65d1fa1f
15 changed files with 28 additions and 16 deletions

View file

@ -12,6 +12,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
@ -157,7 +158,17 @@ func getBuildInfo(name string, src interface{}) (*buildInfo, error) {
default:
panic(fmt.Sprintf("unsupported src type: %T", s))
}
names = append(names, name)
if strings.HasPrefix(runtime.Version(), "go1.15") {
dir, err = ioutil.TempDir("", "*")
if err != nil {
return nil, err
}
name = filepath.Join(dir, filepath.Base(name))
absName = name
names = append(names, "file="+name)
} else {
names = append(names, name)
}
conf.Overlay[absName] = buf
} else {
if strings.HasSuffix(name, ".go") {