For those of us that think go plugins are the most important piece of 
technology to come out since the sandwich toaster, being unable to 'go 
install' a plugin is a problem one wants to solve.

Armed only with ignorance, I attacked this problem head on. Plunging 
directly into src/cmd/go/internal/load/pkg.go, I tried to do things like 
hard code cfg.BuildBuildmode to something to identify later. Easy first 
success!

+       if p.ImportPath == "go.wit.com/toolkits/gocui" {
+               buildmode = "plugin"
+               cfg.BuildBuildmode = "plugin"
+               cfg.BuildO = "/tmp/go/lib/blah2.so"
+       }

The cloak of deception cast, I attacked onwards into 
"cmd/go/internal/work". Here the onslaught of references to "main" 
increased its counterattack. It became evident that in the cases of 
'"main"', some seemed to be involved with 'package main' and others in 
detecting "function main()". There, after many battles in init.go gc.go 
build.go exec.go, etc, wounded and heavily damaged, it was time to retreat.

Let's trick it from the beginning? What is this, some sort of preprocessor 
cmd/go/internal/cfg/cfg.go or cmd/go/internal/load/pkg.go. Let's just 
deceive things at this point. Except it seems, one can only use the words 
in an abridged dictionary down there. Alas, this attack was declared dead 
at 2:25am. This is expected when going into conflict armed only with 
ignorance.

Silliness aside, the idea of:

Changing:
    package main
To:
    package plugin

seems ideal. Another option could be things like adding:

//go:plugin

Is there some plan being developed for this?

In the meantime, I worked around this by modifying a tool I've been using 
'go-clone' to install plugins by looking for a .plugin file in the repo. 
I'm hoping something better like 'package plugin' could be adopted!

Best wishes,
jcarr

go install go.wit.com/apps/go-clone@latest
go install go.wit.com/apps/go-mod-clean@latest
go-clone --recursive --install go.wit.com/ 
<http://go.wit.com/toolkits/gocui>apps/helloworld
go-clone --recursive --install go.wit.com/toolkits/gocui
go-clone --recursive --install go.wit.com/toolkits/ 
<http://go.wit.com/toolkits/gocui>andlabs # uses gtk, works on linux, maybe 
macos too?

NOTES:
   * this works on debian sid
   * I still mainly work in ~/go/src because I can't get go.work files to 
work so although this should work with go.work files, it seems to fail 
sometimes with weird errors. Maybe someone will be able to explain to me 
what I'm doing wrong someday.
   * helloworld doesn't work on the macos yet, but works fine in linux. I 
think it's an AMD64 vs ARM64 issue.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/3717bc32-a952-4f72-a855-5937b2ca2b42n%40googlegroups.com.

Reply via email to