just started using modules, what have i missed? (continuation..)

159 views
Skip to first unread message

simon place

unread,
May 6, 2024, 12:39:39 PMMay 6
to golang-nuts
OK, i had thought, (without understanding why), you can't/don't install non-main packages, as the error message says. ( as mentioned in previous post)

simon@fedora:~$ go install github.com/vulkan-go/vulkan@latest
package github.com/vulkan-go/vulkan is not a main package

but it works sometimes? (still error message)

simon@fedora:~$ go install github.com/xyproto/png2svg@latest
go: downloading github.com/xyproto/png2svg v1.5.4
go: downloading github.com/xyproto/tinysvg v1.1.0
package github.com/xyproto/png2svg is not a main package

and why not install the latest if not specified anyway?

Ian Lance Taylor

unread,
May 6, 2024, 1:04:12 PMMay 6
to simon place, golang-nuts
It didn't work either time. In the second case it just did some other
stuff before noticing.

Before modules, it made sense to "go install" a non-main package: that
would build the package and set it up to be imported by other
packages. With modules, though, it doesn't make any sense. The
go.mod file specifies exactly what version of a non-main package to
use. And the compiled form of packages is stored in the package
cache. Installing a non-main package isn't going to affect how
anything else is built. For a while it was available essentially a
no-op. Now it gets an error.

Ian

simon place

unread,
May 6, 2024, 1:05:09 PMMay 6
to golang-nuts
for this new trial package usage, the main is in a sub-directory,  so i run it .....

main.go:8:2: cannot find module providing package github.com/urfave/cli/v2: import lookup disabled by -mod=vendor
(Go version in go.mod is at least 1.14 and vendor directory exists.)
main.go:9:2: cannot find module providing package github.com/xyproto/palgen: import lookup disabled by -mod=vendor
(Go version in go.mod is at least 1.14 and vendor directory exists.)
../../box.go:8:2: cannot find module providing package github.com/xyproto/tinysvg: import lookup disabled by -mod=vendor
(Go version in go.mod is at least 1.14 and vendor directory exists.)

so install didn't install its packages?

so i get (or should i install) the packages by hand ....

go: downloading github.com/urfave/cli/v2 v2.27.2
go: downloading github.com/urfave/cli v1.22.15
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.4
go: downloading github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: updating go.mod: open /var/home/simon/go/pkg/mod/github.com/xyproto/png...@v1.5.4/go.mod: permission denied

but this didn't help.

at a guess the main in a sub-folder needs to be 'modularised'?

but its installed in the mod folder, which is locked, so that cant be right.

simon place

unread,
May 6, 2024, 1:15:49 PMMay 6
to golang-nuts
@ian thanks, i understand what you say, but i still seem to be stuck.

could i trouble you for a short run-thought of how to use this package?

Message has been deleted

simon place

unread,
May 6, 2024, 1:24:45 PMMay 6
to golang-nuts
On Monday 6 May 2024 at 18:04:12 UTC+1 Ian Lance Taylor wrote:
On Mon, May 6, 2024 at 9:40 AM 'simon place' via golang-nuts
<golan...@googlegroups.com> wrote:
>
> OK, i had thought, (without understanding why), you can't/don't install non-main packages, as the error message says. ( as mentioned in previous post)
>
> simon@fedora:~$ go install github.com/vulkan-go/vulkan@latest
> package github.com/vulkan-go/vulkan is not a main package
>
> but it works sometimes? (still error message)
>
> simon@fedora:~$ go install github.com/xyproto/png2svg@latest
> go: downloading github.com/xyproto/png2svg v1.5.4
> go: downloading github.com/xyproto/tinysvg v1.1.0
> package github.com/xyproto/png2svg is not a main package
>
> and why not install the latest if not specified anyway?

It didn't work either time. In the second case it just did some other
stuff before noticing.


when i tried to run the main package, it was from the folder that got installed by previous?
 

simon place

unread,
May 6, 2024, 1:39:48 PMMay 6
to golang-nuts
OK, got it, i unlocked the cmd folder (under mod) then did the trick i previously mentioned;

add a dummy module then tidied it then sym linked the packages into the src folder.

then removed all and relocked.

this isn't a practical way to add packages, is it.


simon place

unread,
May 6, 2024, 1:42:07 PMMay 6
to golang-nuts
is this all due to 1.22 no longer being backwardly supportive of non-modlarised packages and the large number of non-modularised packages, that are never going to be updated?
Reply all
Reply to author
Forward
0 new messages