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

slog type error on v0.6.5 #2004

Closed
Watt3r opened this issue Jul 17, 2024 · 4 comments
Closed

slog type error on v0.6.5 #2004

Watt3r opened this issue Jul 17, 2024 · 4 comments

Comments

@Watt3r
Copy link

Watt3r commented Jul 17, 2024

I'm upgrading a package I'm using from v0.4.1 -> v0.6.5.

I'm struggling a bit with slog. Has anyone seen this issue before? What's the fix?

My code is https://github.com/Watt3r/d2-live

When I run go run, I get this error:

# oss.terrastruct.com/d2/lib/log
../../go/pkg/mod/oss.terrastruct.com/d2@v0.6.5/lib/log/log.go:52:28: cannot use fields (variable of type []slog.Field) as []any value in argument to from(ctx).Debug
../../go/pkg/mod/oss.terrastruct.com/d2@v0.6.5/lib/log/log.go:57:27: cannot use fields (variable of type []slog.Field) as []any value in argument to from(ctx).Info
../../go/pkg/mod/oss.terrastruct.com/d2@v0.6.5/lib/log/log.go:62:27: cannot use fields (variable of type []slog.Field) as []any value in argument to from(ctx).Warn
../../go/pkg/mod/oss.terrastruct.com/d2@v0.6.5/lib/log/log.go:67:28: cannot use fields (variable of type []slog.Field) as []any value in argument to from(ctx).Error
../../go/pkg/mod/oss.terrastruct.com/d2@v0.6.5/lib/log/log.go:72:31: cannot use fields (variable of type []slog.Field) as []any value in argument to from(ctx).Critical
../../go/pkg/mod/oss.terrastruct.com/d2@v0.6.5/lib/log/log.go:77:28: cannot use fields (variable of type []slog.Field) as []any value in argument to from(ctx).Fatal

Any help would be appreciated.

@bo-ku-ra
Copy link
Contributor

My code is https://github.com/Watt3r/d2-live

c.f. #1213 (comment)

For example,

https://api.d2lang.com/render/svg?layout=dagre&theme=7&sketch=1&script=<encoded_string>

https://api.d2lang.com/render/svg?layout=dagre&theme=7&sketch=1&script=qlDQtVOo5AIEAAD__w%3D%3D

@Watt3r
Copy link
Author

Watt3r commented Jul 17, 2024

Wow, weird that is so hidden would've saved me a lot of trouble thanks

I am still wondering how to fix the golang issue, just for my own sanity

@bo-ku-ra
Copy link
Contributor

bo-ku-ra commented Jul 17, 2024

i do not understand the golang issue.
but i hope this will help you to improve your product.

here is my use case.

i can draw directly from 'D2 Playgraund' by the following bookmarklet.

javascript:(function(){var url = location.href; var redirect_url = url.replace("https://play.d2lang.com/?", "https://api.d2lang.com/render/svg?"); window.open(redirect_url,'_blank'); })()

@alixander
Copy link
Collaborator

alixander commented Jul 18, 2024

@Watt3r indeed, this is a known thing. Slog made some backwards incompatible changes that we don't agree with, so we version locked to our current. I have this line to projects that import d2

replace cdr.dev/slog => cdr.dev/slog v1.4.2

see https://go.dev/ref/mod#go-mod-file-replace for more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants