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

code: remove slog dependency #1637

Closed
alixander opened this issue Oct 4, 2023 · 3 comments · Fixed by #2137
Closed

code: remove slog dependency #1637

alixander opened this issue Oct 4, 2023 · 3 comments · Fixed by #2137

Comments

@alixander
Copy link
Collaborator

No description provided.

@cyborg-ts cyborg-ts added this to D2 Oct 4, 2023
@lukasbindreiter
Copy link

@alixander

Is this planned to be implemented in the near future?

Because especially when using d2 as a library in another go project this is a bit of an issue already - since d2 is only compatible with cdr.dev/slog <= 1.5, the latest slog version has some backward incompatible changes:

# oss.terrastruct.com/d2/lib/log
../../../go/pkg/mod/oss.terrastruct.com/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/lib/log/log.go:77:28: cannot use fields (variable of type []slog.Field) as []any value in argument to from(ctx).Fatal

This means whenever I ugrade dependencies in my project, I typically do:

go get -u ./...
// then manually edit go.mod and revert cdr.dev/slog to 1.5 otherwise it won't compile anymore
go build ./...
// and then do some testing to see everything works

Go now even offers a slog package in the standard libary:
https://go.dev/blog/slog

I think it would make lot's of sense to adapt this instead.

@lukasbindreiter
Copy link

@alixander

I just realized it's even more of an issue than what I thought, there seems to be something breaking this with d2 v0.6.7.

Steps:

  1. create an empty new go project
  2. run go get oss.terrastruct.com/d2
  3. this will download and add d2 v0.6.7 and cdr.dev/slog v1.6.1 to the project, which won't compile
  4. manually downgrading slog to v1.5.0 won't work, as soon as you run go get it upgrades it again
  5. So I have to both pin terrastruct/d2 to v0.6.6 and cdr.dev/slog to v1.5.0

I've noticed that you have a replace directive in place:

d2/go.mod

Line 7 in 8223e86

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

However, i want to avoid this in our case, it seems a bit hacky.

@alixander
Copy link
Collaborator Author

@lukasbindreiter thank you for bringing attention to this. I'll prioritize this week

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

Successfully merging a pull request may close this issue.

2 participants