Open AGWA opened 3 weeks ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
CC @golang/telemetry
Thanks. My understanding is that os.UserConfigDir
was chosen for its portability, and to consolidate all the telemetry data in one place. However, we may be able to use more appropriate directories on POSIX systems.
For the record the rationale for choosing $XDG_STATE_HOME
over $XDG_DATA_HOME
is that this data is not portable, and relates to specific application state? If so, it may be that $XDG_STATE_HOME
is most appropriate for counter files and logs, and $XDG_DATA_HOME
is most appropriate for consolidated the weekly JSON summaries (local or uploaded reports).
$XDG_STATE_HOME
is for application state, whereas $XDG_DATA_HOME
is intended for things like font or icon files (the sort of stuff that is found in /usr/share
), though many applications put state there because $XDG_STATE_HOME
didn't always exist. So all telemetry data, including the weekly JSON summaries, belong in $XDG_STATE_HOME
.
See https://lists.freedesktop.org/archives/xdg/2016-December/013803.html, https://wiki.debian.org/XDGBaseDirectorySpecification, and https://www.reddit.com/r/linux/comments/ny34vs/new_xdg_state_home_in_xdg_base_directory_spec/ for background.
Notes from our meeting discussion of this issue:
go env GOTELEMETRYDIR
.os.UserConfigDir
as the definition of where data is stored. The complexity of having a more complicated heuristic could harm the clarity of our documentation.mode
or weekends
file) from data which is stateful (counters and reports). It may actually be cleaner to have state in a separate directory, as then the clean
operation becomes trivial.So, my current sense is that while XDG_STATE_HOME may be the more appropriate directory on Linux, it's not clear whether the upside of making this change now offsets the downside. If there were something like os.UserStateDir
, that downside would be significantly reduced, but does such an API make sense if there aren't good analogs on Windows (or even Mac?).
Go version
go version go1.23.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
What did you see happen?
My
$XDG_CONFIG_HOME/go/telemetry
directory ($HOME/.config/go/telemetry
) is now full of data files, in violation of the XDG Base Directory Specification which reserves$XDG_CONFIG_HOME
for configuration.What did you expect to see?
I expected telemetry data to be stored in
$XDG_STATE_HOME
instead.