Re: [go-nuts] Permissions in ~/go/pkg

2024-05-10 Thread Tobias Klausmann
Hi! On Fri, 10 May 2024, Ian Lance Taylor wrote: > This is a choice made by Go. You can override with the -modcacherw > option to "go build", "go test", "go install", and similar code. You > can make that option the default by setting GOFLAGS in the environment > or via "go env GOFLAGS=...". >

[go-nuts] Permissions in ~/go/pkg

2024-05-10 Thread Tobias Klausmann
Hi! I test and try a whole load of Go tools and libraries, and as a result, my ~go/pkg dir quickly grows. While I'd love some kind of automatic expiry for that cache, I am fine with just occasionally running rm-rf on that dir myself. ... except it doesn't work. For some unclear reason, some of

Re: [go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread Tobias Klausmann
Hi! On Thu, 14 Sep 2023, Brian Candler wrote: > Could you just unmarshal it to a map[string]IntTSList, and then walk it and > build whatever structure you want? I will try and make that work tomorrow, thanks for the hint! > If you want to pick certain fixed fields into a struct and separate out

Re: [go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread Tobias Klausmann
Hi! On Thu, 14 Sep 2023, Peter Galbavy wrote: > You will need to create a custom type and unmarshal method. Plenty of > example if you search for "golang custom json unmarshal". > > As I've only had to implement it for a couple of simple types I can't offer > my own valid example. I am aware

[go-nuts] Parsing difficult JSON

2023-09-14 Thread Tobias Klausmann
Hi! I am trying to write Prometheus exporter for stats queried fro the Kea DHCP server. Unfortunatly, the JSON is structured very badly if I want to use the base library JSON Unmarshal functionality: { "arguments": { "cumulative-assigned-addresses": [ [ 1, "2023-09-13

[go-nuts] Using msotly plain slog, but changing the log.Logger underneath?

2023-08-12 Thread Tobias Klausmann
Hi! So I have been looking at golang v1.21, and while I like the slog package in principle, it really annoys me that there is no way to get a new slog Logger *that I can specify the underlying log.Logger for*. It seems I have to implement a complete slog.Handler myself, which is six miles of

Re: [go-nuts] Idiomatic distribute-process-collect pattern

2023-05-21 Thread Tobias Klausmann
Hi! First off, thanks both Ian and Andrew! On Sat, 20 May 2023, Ian Lance Taylor wrote: > On Sat, May 20, 2023 at 1:23 AM Tobias Klausmann > wrote: > > What I wonder about is the collection stage: the assumption that there > > will be exactly as many results as in

[go-nuts] Idiomatic distribute-process-collect pattern

2023-05-20 Thread Tobias Klausmann
Hi! I find myself often writing tools that follow the pattern in the subject, that is: - Gather some input to process, e.g. a list of filenames from the command line. If this can be streamed (processing starting before knowing all inputs) even better, but not strictly necessary. - Start N

Re: [go-nuts] extract VCS branch name used during build

2023-02-07 Thread Tobias Klausmann
Hi! On Mon, 06 Feb 2023, quin...@gmail.com wrote: > I would like to be able to extract the VCS branch name used during build. > Currently I append "-X main.BranchName=${BRANCH}" to the build line which > works, but I was hoping there might be a cunning way to extract this from > runtime/debug?

Re: [go-nuts] when doing a WalkDir of a FileSystem, how do you get access to the path that you are working on

2023-01-15 Thread Tobias Klausmann
Hi! On Sat, 14 Jan 2023, Pat Farrell wrote: > On Saturday, January 14, 2023 at 6:52:15 PM UTC-5 raf wrote: >> The function you implement (WalkDirFunc should receive "p" as the path to >> the parent (that seems to be what you want) and "d" as the current >> directory entry. I am not sure why

Re: [go-nuts] Very curious, why is "3:04 PM" named Kitchen in the time package?

2022-09-23 Thread Tobias Klausmann
Hi! On Fri, 23 Sep 2022, fliter wrote: > Is it because it is time to go to the kitchen to cook? It seems that 3:04 > PM is too early My best guess: it's the most common way kitchen timers that also are clocks display the time. It's not the specific time that is "kitchen"-likem, but rather the

Re: [go-nuts] Looping and tail-end code

2022-01-12 Thread Tobias Klausmann
Hi! On Wed, 12 Jan 2022, Rob Pike wrote: > What's wrong with >for ;; time.Sleep(delay) { ... } > ? > > This technique is as old as the hills. Or at least as old as C for loops. Never been a C guy :) Thanks, that works perfectly! Best, Tobias -- You received this message because you are

[go-nuts] Looping and tail-end code

2022-01-12 Thread Tobias Klausmann
Hi! Often with tools that poll something, you get code of this form: ``` for { r, err := doSomeCall() if err != nil { log.Printf("Some error:", err) continue } s, err := doSomeOtherCall(r) if err != nil {

Re: [go-nuts] Re: A peculiar sort problem

2021-07-28 Thread Tobias Klausmann
Hi! On Tue, 27 Jul 2021, Tamás Gulácsi wrote: > First, sort all the bytes (0-255) with Go and .Net, and compare them. > For Unicode-unaware sorting, that'd be enough: create a mapping between the > two tables, > replace all the bytes in the Go's input before sort (or use a Less that > does

Re: [go-nuts] Re: A peculiar sort problem

2021-07-28 Thread Tobias Klausmann
Hi! On Wed, 28 Jul 2021, James wrote: > It could be that .NET is using some locale based collation. Seems like a > lot of machinery, but might do the trick > https://pkg.go.dev/golang.org/x/text@v0.3.6/collate I have managed to get the .NET code used for sorting: Files.Sort((x, y) =>

[go-nuts] A peculiar sort problem

2021-07-27 Thread Tobias Klausmann
Hi! I am writing a tool that handles files and generates some sorted output. Since this tool is to be a replacement for part of another system (written in C#/.NET), the output must be a byte-exact duplicate. The existing system generates some checksums and filenames in a stable sorted order,