Index | Thread | Search

From:
Tim van der Molen <tim@kariliq.nl>
Subject:
Re: [update] lang/go to 1.22.4; add missed syscall.EBADMSG
To:
OpenBSD ports <ports@openbsd.org>, Joel Sing <jsing@openbsd.org>
Date:
Fri, 7 Jun 2024 18:14:45 +0200

Download raw body.

Thread
Kirill A. Korinsky (2024-06-07 15:34 +0100):
> > afaik they're meant to be getting these from golang.org/x/sys/unix
> > (where EBADMSG *is* present for all OpenBSD platforms) rather than
> > go itself anyway?
> 
> I've already tried it and discovered an issue that x/sys/unix isn't
> available on windows that is expected, but syscall.EBADMSG is available on
> windows. My approach to replace it in fsutil fails on CI [1].
> 
> As far as I know go hasn't got condition compiling that allows to inclide or
> exclude some block of code inside file and the only way is making dedicated
> files which is used at some platforms, that means quite a work to refactor
> fsutil to move away from syscall to x/sys.
> 
> Footnotes:
> [1]  https://github.com/catap/fsutil/commit/aa976fb00b3a25d23bacb193c5dfcf13d7db7199#diff-d1445ba8bd61e8e9f66950832df5b1d76f222e7f1f38700a30b728c214da04ccL126-L129

Is the following approach feasible in fsutil?

Create errors_unix.go:

	//go:build unix

	import "golang.org/x/sys/unix"

	const (
		ebadmsg = unix.EBADMSG
		eexist  = unix.EEXIST
		enotdir = unix.ENOTDIR
	)

Create errors_windows.go:

	import "syscall"

	const (
		ebadmsg = syscall.EBADMSG
		// ...
	)

Then replace "syscall.EBADMSG" with "ebadmsg" in the other files (and
similarly for the other errors).