fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.14k stars 1.4k forks source link

fyne brokenimport #4439

Closed cartmanarlekin closed 11 months ago

cartmanarlekin commented 11 months ago

Checklist

Describe the bug

could not import fyne.io/fyne/v2/app (no required module provides package "fyne.io/fyne/v2/app")

[{ "resource": "/C:/Users/cartm/Desktop/golanga/main.go", "owner": "_generated_diagnostic_collectionname#0", "code": { "value": "BrokenImport", "target": { "$mid": 1, "path": "/golang.org/x/tools/internal/typesinternal", "scheme": "https", "authority": "pkg.go.dev", "fragment": "BrokenImport" } }, "severity": 8, "message": "could not import fyne.io/fyne/v2/app (no required module provides package \"fyne.io/fyne/v2/app\")", "source": "compiler", "startLineNumber": 4, "startColumn": 2, "endLineNumber": 4, "endColumn": 23 }]

How to reproduce

i just download and install fyne and run this code: "package main

import ( "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" )

func main() { a := app.New() w := a.NewWindow("Hello")

hello := widget.NewLabel("Hello Fyne!")
w.SetContent(container.NewVBox(
    hello,
    widget.NewButton("Hi!", func() {
        hello.SetText("Welcome :)")
    }),
))

w.ShowAndRun()

} " and i get 3 errors "brockenimport" for this import ( "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" ) and if i do mod tidy - go downloaded fyne v1.

Screenshots

Screenshot 2023-12-06 044607

Example code

package main

import ( "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" )

func main() { a := app.New() w := a.NewWindow("Hello")

hello := widget.NewLabel("Hello Fyne!")
w.SetContent(container.NewVBox(
    hello,
    widget.NewButton("Hi!", func() {
        hello.SetText("Welcome :)")
    }),
))

w.ShowAndRun()

}

Fyne version

2.4.2

Go compiler version

1.21.4

Operating system and version

windows 11

Additional Information

No response

andydotxyz commented 11 months ago

Please show the output of "go mod tidy"

jgardona commented 11 months ago

@cartmanarlekin tested your code here and I cant reproduce the issue. All goes ok

image

Workspace/go/fyneexample via 🐹 v1.21.5
❯ go build -v
fyne.io/fyne/v2/internal/color
golang.org/x/net/html/atom
golang.org/x/text/encoding/internal/identifier
golang.org/x/text/internal/utf8internal
golang.org/x/text/internal/tag
golang.org/x/text/transform
runtime/cgo
golang.org/x/sys/unix
golang.org/x/net/html
golang.org/x/sys/execabs
golang.org/x/text/internal/language
golang.org/x/text/encoding
golang.org/x/text/runes
golang.org/x/text/encoding/internal
golang.org/x/text/encoding/unicode
golang.org/x/text/encoding/charmap
golang.org/x/text/encoding/japanese
golang.org/x/text/encoding/traditionalchinese
golang.org/x/text/encoding/simplifiedchinese
golang.org/x/text/encoding/korean
golang.org/x/text/internal/language/compact
golang.org/x/text/language
golang.org/x/text/encoding/htmlindex
os/user
github.com/go-gl/glfw/v3.3/glfw
net
github.com/go-gl/gl/v3.2-core/gl
golang.org/x/net/html/charset
github.com/srwiley/oksvg
github.com/fsnotify/fsnotify
github.com/go-text/render
vendor/golang.org/x/net/http/httpproxy
github.com/fredbi/uri
net/textproto
crypto/x509
github.com/godbus/dbus/v5
vendor/golang.org/x/net/http/httpguts
crypto/tls
fyne.io/systray/internal/generated/notifier
fyne.io/systray/internal/generated/menu
fyne.io/systray
net/http/httptrace
net/http
fyne.io/fyne/v2
fyne.io/fyne/v2/internal/scale
fyne.io/fyne/v2/internal/cache
fyne.io/fyne/v2/driver/mobile
fyne.io/fyne/v2/internal/animation
fyne.io/fyne/v2/storage/repository
fyne.io/fyne/v2/internal/svg
fyne.io/fyne/v2/driver/desktop
fyne.io/fyne/v2/internal/async
fyne.io/fyne/v2/storage
fyne.io/fyne/v2/internal/driver
fyne.io/fyne/v2/internal/repository
fyne.io/fyne/v2/canvas
fyne.io/fyne/v2/data/binding
fyne.io/fyne/v2/internal/app
fyne.io/fyne/v2/theme
fyne.io/fyne/v2/internal/painter
fyne.io/fyne/v2/internal/widget
fyne.io/fyne/v2/layout
fyne.io/fyne/v2/internal
fyne.io/fyne/v2/widget
fyne.io/fyne/v2/container
fyne.io/fyne/v2/internal/painter/gl
fyne.io/fyne/v2/internal/driver/common
fyne.io/fyne/v2/internal/driver/glfw
fyne.io/fyne/v2/app
fyneexample

Workspace/go/fyneexample via 🐹 v1.21.5 took 3m46s
❯ go mod tidy -v

image

Maybe a vscode issue?

cartmanarlekin commented 11 months ago

@jgardona , Very interesting and strange, because... I thought I had fixed this problem, but it was followed by another, but in the same vein... I will not refuse tips: https://github.com/fyne-io/fyne/issues/4455

andydotxyz commented 11 months ago

They are not related - the follow-on issue has been resolved as the import paths being incorrect. This one does look like a VSCode issue but I am very glad you got it sorted.

cartmanarlekin commented 10 months ago

@andydotxyz But I don’t know how to fix this, because vscode independently changes the link in the import from “/widget” to “/container/widget” and as a result, the import does not work, even if I use GoLand - the problem does not disappear.

Jacalz commented 10 months ago

If that’s the case, open a bug report at https://github.com/golang/vscode-go. Or maybe not if you have the same issue in GoLand? I have never personally seen this issue and as Andrew pointed out, those packages don’t exist and never have existed.