Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong implementation of Join function for older go versions #28

Closed
peczenyj opened this issue Nov 10, 2023 · 0 comments · Fixed by #30
Closed

wrong implementation of Join function for older go versions #28

peczenyj opened this issue Nov 10, 2023 · 0 comments · Fixed by #30

Comments

@peczenyj
Copy link
Contributor

Hello

errors/join.go

Line 54 in 10bc51a

return unsafe.String(&b[0], len(b))

this will not work for go versions older than 1.20

the reason is: unsafe.String was added on 1.20

this code will not compile on go 1.19, for instance

an alternative is to use unsafe.Pointer like in the example below

https://github.com/valyala/fasthttp/blob/master/b2s_old.go

however there is another issue: the signature of Unwrap method uses a new alternative format (when return an slice of errors)

errors/join.go

Line 57 in 10bc51a

func (e *joinError) Unwrap() []error {

but for older versions of go this Unwrap signature:

errors/wrap.go

Line 40 in 10bc51a

func Unwrap(err error) error {

will use the standard errors package that does not support it.

IMHO we should drop this implementation (or specify an Unwrap function for older versions that supports both signatures) since the go.mod specifies go 1.20

and change the Join implementation for newer version of go to be a function that delegate the call to errors package like we do for Unwrap instead specify a public global variable that points to the Join function.

@peczenyj peczenyj changed the title wrong implementation of join functions for older go versions wrong implementation of Join function for older go versions Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant