Re: macOS and go language bindings

Subject: Re: macOS and go language bindings

Date: Tue, 21 Nov 2023 16:00:13 -0500

To: Carl Worth, notmuch@notmuchmail.org

Cc:

From: Peter Lawrence


On Tue Nov 21, 2023 at 2:19 PM EST, Carl Worth wrote:
> On Sun, Nov 19 2023, Peter Lawrence wrote:
> > Hi.
>
> Hi Peter!
>
> >     I'm trying to build an email client (aerc) with support for notmuch
> > on macOS. aerc is written in go. I can't find an aerc package for brew
> > which includes notmuch headers/library files.  Where can I get these
> > language bindings and how do I "install" them, or where do I place them
> > in the aerc source directory to get the notmuch library built and then
> > accessible to aerc?
>
> I don't have much direct experience with either macOS nor the Go
> language bindings to notmuch, but I'll see how far I can get in
> answering your questions.
>
> The Go bindings for notmuch are in the contrib/go directory of the
> source distribution which you can get from the latest source release
>
>
> 	https://notmuchmail.org/releases/notmuch-0.38.tar.xz
>
> Or via git:
>
> 	git clone https://git.notmuchmail.org/git/notmuch
>
> There's a brief README and a Makefile in the contrib/go directory, but
> I'm not exactly clear on how things are supposed to work.
>
> When I type "make" the first command it runs is "go install notmuch"
> which fails as follows:
>
> $ go install notmuch
> go: 'go install' requires a version when current directory is not in a module
> 	Try 'go install notmuch@latest' to install the latest version
>
> The advice from the error message doesn't help much:
>
> $ go install notmuch@latest
> go: notmuch@latest: malformed module path "notmuch": missing dot in first path element
>
> I'm guessing someone who knows even a tiny bit about go modules might be
> able to explain what's needed here, so we can fix the Makefile to
> actually work?
>
> -Carl


Thanks for the feedback, Carl!

I have a feeling now that this isn't just a macOS issue, but possibly a
broader issue that would effect anyone using a newer version of Go. I
followed your steps as well and got the same results. It seems that Go
changed some things around release 1.13 such that there is now a
"module" mode for Go instead of a GOPATH mode. Newer versions of Go
default to using the module mode rather than GOPATH mode. I found this 
blurb about Go environment variables: 

GO111MODULE
	Controls whether the go command runs in module-aware mode or GOPATH mode.
	May be "off", "on", or "auto".
	See https://golang.org/ref/mod#mod-commands.

So, I set my GO111MODULE to off with this command:
    go env -w GO111MODULE="off"

This helped. Then, I had to strip out some commented out lines in the
notmuch.go file under src/

Now when I compile with "make", I get some 75 lines of errors, similar
to the following:

src/notmuch/notmuch.go:89:8: could not determine kind of name for C.free
src/notmuch/notmuch.go:1047:8: could not determine kind of name for C.notmuch_bool_t
src/notmuch/notmuch.go:251:15: could not determine kind of name for C.notmuch_database_add_message
src/notmuch/notmuch.go:96:15: could not determine kind of name for C.notmuch_database_create
src/notmuch/notmuch.go:140:16: could not determine kind of name for C.notmuch_database_destroy
src/notmuch/notmuch.go:315:15: could not determine kind of name for C.notmuch_database_find_message

I am guessing that the go compiler (mine is at 1.20.8) doesn't like the
source in notmuch.go. This may have been written a while ago?  I'm
definitely over my head in the Go world at this point.

I wonder if anyone proficient with Go might know how to get the source
to build against a Go 1.20+ version?


-- 
Peter Lawrence

signature.asc (application/pgp-signature)
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: