Module weirdness in playground

54 views
Skip to first unread message

Brian Candler

unread,
Nov 18, 2022, 1:15:36 PM11/18/22
to golang-nuts
This used to work:

But now when I click on "Run", the import path of "example.com/myprog/foo" is removed, and it fails to compile.

Any clues as to what's going on?

Jan Mercl

unread,
Nov 18, 2022, 1:29:01 PM11/18/22
to Brian Candler, golang-nuts
I think the playground uses goimports.

Brian Candler

unread,
Nov 18, 2022, 1:37:53 PM11/18/22
to golang-nuts
Interesting.  But if I install and run goimports locally, it doesn't delete the import - it just rewrites it to assign the package name explicitly.  Maybe the playground has a different version of goimports?

$ ~/go/bin/goimports -d .
diff -u start.go.orig start.go
--- start.go.orig       2022-11-18 18:35:27.000000000 +0000
+++ start.go    2022-11-18 18:35:27.000000000 +0000
@@ -1,8 +1,9 @@
 package main

 import (
-       "example.com/myprog/foo"
        "fmt"
+
+       wibble "example.com/myprog/foo"
 )

 func main() {

Reply all
Reply to author
Forward
0 new messages