cosmos72 / gomacro

Interactive Go interpreter and debugger with REPL, Eval, generics and Lisp-like macros
Mozilla Public License 2.0
2.18k stars 94 forks source link

Unable to import 3rd party packages in version go1.16.2 darwin/amd64 #108

Closed coghost closed 3 years ago

coghost commented 3 years ago

Hi I check https://github.com/cosmos72/gomacro/issues/89 and https://github.com/cosmos72/gomacro/issues/58 but still cann't import 3rd party packages, I'm not familiar to golang, please help me to find out why, Thanks!

❯                                                                                                                                                          ─╯
❯ go version
go version go1.16.2 darwin/amd64
❯ gomacro
// Welcome to gomacro. Type :help for help, :copy for copyright and license.
// This is free software with ABSOLUTELY NO WARRANTY.
gomacro> import "github.com/chromedp/chromedp"
// debug: looking for package "github.com/chromedp/chromedp" ...
error loading package "github.com/chromedp/chromedp" metadata: -: no required module provides package github.com/chromedp/chromedp; to add it:
    go get github.com/chromedp/chromedp
gomacro>
gomacro>
❯ go get -u github.com/chromedp/chromedp
❯ gomacro
// Welcome to gomacro. Type :help for help, :copy for copyright and license.
// This is free software with ABSOLUTELY NO WARRANTY.
gomacro> import "github.com/chromedp/chromedp"
// debug: looking for package "github.com/chromedp/chromedp" ...
error loading package "github.com/chromedp/chromedp" metadata: -: no required module provides package github.com/chromedp/chromedp; to add it:
    go get github.com/chromedp/chromedp
gomacro> import "github.com/aws/aws-sdk-go/aws"
// debug: looking for package "github.com/aws/aws-sdk-go/aws" ...
error loading package "github.com/aws/aws-sdk-go/aws" metadata: -: no required module provides package github.com/aws/aws-sdk-go/aws; to add it:
    go get github.com/aws/aws-sdk-go/aws
gomacro>
❯ go get github.com/aws/aws-sdk-go/aws
go: downloading github.com/aws/aws-sdk-go v1.37.31
go get: added github.com/aws/aws-sdk-go v1.37.31
❯ gomacro
// Welcome to gomacro. Type :help for help, :copy for copyright and license.
// This is free software with ABSOLUTELY NO WARRANTY.
gomacro> import "github.com/aws/aws-sdk-go/aws"
// debug: looking for package "github.com/aws/aws-sdk-go/aws" ...
error loading package "github.com/aws/aws-sdk-go/aws" metadata: -: no required module provides package github.com/aws/aws-sdk-go/aws; to add it:
    go get github.com/aws/aws-sdk-go/aws
gomacro>
cosmos72 commented 3 years ago

It seems that import of third-party packages is broken in Go 1.16.x

Thanks for spotting this, I will work to fix it.

cosmos72 commented 3 years ago

UPDATE: a partial fix is available in commit 60b0972adf4face6c2e72d96f426b57b7d83e11c it only works if the package being imported does not depend on other modules

I will continue working on a full bugfix.

As a temporary workaround, you can downgrade to Go 1.15.x and recompile gomacro.

cosmos72 commented 3 years ago

UPDATE: an improved (and hopefully complete) fix is available in commit 0b986404ea464b36ce0ce7bba1a720af70f407fd

wdscxsj commented 3 years ago

Working fine. Thanks!

coghost commented 3 years ago

Great Job, thanks, it works now!

❯ gomacro
// Welcome to gomacro. Type :help for help, :copy for copyright and license.
// This is free software with ABSOLUTELY NO WARRANTY.
gomacro> import (
. . . .    "time"
. . . .    "github.com/go-rod/rod"
. . . .    "github.com/go-rod/rod/lib/input"
. . . .    "github.com/go-rod/rod/lib/launcher"
. . . .    )
// debug: running "go get github.com/go-rod/rod" ...
go get: added github.com/go-rod/rod v0.95.0
// debug: running "go mod tidy" ...
// debug: compiling "/Users/:)/go/src/gomacro.imports/github.com/go-rod/rod/rod.go" ...
// debug: running "go get github.com/go-rod/rod/lib/input" ...
go get: added github.com/go-rod/rod v0.95.0
// debug: running "go mod tidy" ...
// debug: compiling "/Users/:)/go/src/gomacro.imports/github.com/go-rod/rod/lib/input/input.go" ...
// debug: running "go get github.com/go-rod/rod/lib/launcher" ...
go get: added github.com/go-rod/rod v0.95.0
// debug: running "go mod tidy" ...
// debug: compiling "/Users/:)/go/src/gomacro.imports/github.com/go-rod/rod/lib/launcher/launcher.go" ...
gomacro>
❯ gomacro
// Welcome to gomacro. Type :help for help, :copy for copyright and license.
// This is free software with ABSOLUTELY NO WARRANTY.
gomacro> import (
. . . .    "time"
. . . .    "github.com/go-rod/rod"
. . . .    "github.com/go-rod/rod/lib/input"
. . . .    "github.com/go-rod/rod/lib/launcher"
. . . .    )
// debug: running "go get github.com/go-rod/rod" ...
go get: added github.com/go-rod/rod v0.95.0
// debug: running "go mod tidy" ...
// debug: compiling "/Users/:)/go/src/gomacro.imports/github.com/go-rod/rod/rod.go" ...
// debug: running "go get github.com/go-rod/rod/lib/input" ...
go get: added github.com/go-rod/rod v0.95.0
// debug: running "go mod tidy" ...
// debug: compiling "/Users/:)/go/src/gomacro.imports/github.com/go-rod/rod/lib/input/input.go" ...
// debug: running "go get github.com/go-rod/rod/lib/launcher" ...
go get: added github.com/go-rod/rod v0.95.0
// debug: running "go mod tidy" ...
// debug: compiling "/Users/:)/go/src/gomacro.imports/github.com/go-rod/rod/lib/launcher/launcher.go" ...
gomacro>
gomacro>