Re: [go-nuts] detecting cyclic references

2020-11-14 Thread twp...@gmail.com
> My use case is that I want to pretty print in-memory objects for debug purposes during testing, and one of the features would be to point out such cycles as this. Consider using an existing library for this, for example: https://github.com/sanity-io/litter https://github.com/davecgh/go-spe

[go-nuts] [ANN] [Geospatial] New set of Go bindings for GEOS

2021-06-20 Thread twp...@gmail.com
GEOS is the standard geometry library that underpins PostGIS and much of the open source geospatial world. https://github.com/twpayne/go-geos is a new set of Go bindings for GEOS that make it easy to use GEOS geometries in your Go applications. Features include: - Fluent Go API. - Low-le

Re: [go-nuts] Getting cross-package test coverage data?

2021-09-29 Thread twp...@gmail.com
Very, very, late response to this, but I was missing the `-coverpkg=./...` argument to `go test`. /facepalm On Thursday, May 14, 2020 at 10:46:43 AM UTC+2 ppi...@gmail.com wrote: > Not sure if a tool is required. > It can be done with a couple of commands. > An elaborate example (of coverage a

Re: [go-nuts] Performance of syscall calls vs. CGO

2022-01-23 Thread twp...@gmail.com
Two tips from writing github.com/twpayne/go-geos (Go bindings for the popular GEOS geometry library), where I also encountered performance problems with cgo when calling small C functions: 1. Make each cgo call do more by moving common combinations of functions in to C, i.e. use a higher-level

[go-nuts] Re: BPF target

2022-02-26 Thread twp...@gmail.com
https://tinygo.org/ might be a more suitable initial project for compiling Go to eBPF. A lot is already in place including an LLVM backend and a simplified Go runtime suitable for small systems. On Thursday, February 24, 2022 at 6:41:00 PM UTC+1 stalke...@protonmail.ch wrote: > With the Solana

Re: [go-nuts] Improving on unit test styles

2022-03-03 Thread twp...@gmail.com
To identify failing test cases in a table of tests where you don't have individual names you can use its index: for i, testCase := range testCases { t.Run(strconv.Itoa(i), func(t *testing.T) { // ... For debugging an individual test case, just skip over all but the failin

[go-nuts] [ANN] go-xmlstruct: generate Go structs from multiple XML documents

2022-11-17 Thread twp...@gmail.com
There are a few existing XML document-to-Go struct generators, but none of them had all of the following features: * Taking multiple XML documents as input. * Generating correct field types. * Customizable field names. * Handling optional and repeated elements. * Ignoring whitespace. If you need

[go-nuts] Does Go optimize math.Float64frombits(binary.LittleEndian.Uint64[...])) to a single instruction?

2022-11-24 Thread twp...@gmail.com
tl;dr: on 64-bit little-endian machines, does x := math.Float64frombits(binary.LittleEndian.Uint64(byteSlice[:8])) get optimized to a single move instruction from byteSlice[:8] to x? Background info: I'm currently writing a bunch of code that unmarshals binary data. A small example is thi

Re: [go-nuts] go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

2023-11-08 Thread twp...@gmail.com
For info, this is broken in Fedora 39, released a day or two ago: $ docker pull fedora:latest $ docker run -it fedora:latest /bin/bash [root@01330dfaac82 /]# dnf update && dnf install -y golang ... [root@01330dfaac82 /]# go version go version go1.21.3 linux/amd64 [root@01330dfaac82 /]# go tool dis

Re: [go-nuts] go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

2023-11-08 Thread twp...@gmail.com
Reported to Fedora at https://bugzilla.redhat.com/show_bug.cgi?id=2248782 On Thursday, November 9, 2023 at 1:00:55 AM UTC+1 twp...@gmail.com wrote: > For info, this is broken in Fedora 39, released a day or two ago: > > $ docker pull fedora:latest > $ docker run -it fedora:late

[go-nuts] rsc.io/script: How to contribute?

2024-03-06 Thread twp...@gmail.com
Internally, Go has a very nice package for integration testing . Roger Peppe has been doing a fantastic service by making it public and maintaining it as a community project at github.com/rogpeppe

[go-nuts] Re: rsc.io/script: How to contribute?

2024-03-06 Thread twp...@gmail.com
*rsc.io/script On Wednesday, March 6, 2024 at 10:46:23 PM UTC+1 twp...@gmail.com wrote: > Internally, Go has a very nice package for integration testing > <https://github.com/golang/go/tree/master/src/cmd/go/internal/script>. > > Roger Peppe <https://github.com/rogpe

[go-nuts] Re: rsc.io/script: How to contribute?

2024-03-07 Thread twp...@gmail.com
ommander-cli. > > On Wednesday, March 6, 2024 at 1:52:57 PM UTC-8 twp...@gmail.com wrote: > >> *rsc.io/script >> >> On Wednesday, March 6, 2024 at 10:46:23 PM UTC+1 twp...@gmail.com wrote: >> >>> Internally, Go has a very nice package for integration testing >

Re: [go-nuts] Re: rsc.io/script: How to contribute?

2024-03-07 Thread twp...@gmail.com
e more modern rsc.io/script, then I'm keen to contribute to rsc.io/script to make it useable by other projects. But first, I need to know how to contribute to rsc.io/script... On Thursday, March 7, 2024 at 3:18:51 PM UTC+1 Eli Bendersky wrote: > On Thu, Mar 7, 2024 at 5:44 AM twp...@gmai

Re: [go-nuts] rsc.io/script: How to contribute?

2024-03-08 Thread twp...@gmail.com
Many thanks for the response Russ. It's clear I should stick with testscript for now. Regards, Tom On Friday, March 8, 2024 at 3:04:10 AM UTC+1 Russ Cox wrote: > Hi all, > > I published rsc.io/script for people to play with, to support my testing > talk . Fo

[go-nuts] pkg.go.dev: redirect URL for latest major version or big red warning for old version

2024-04-08 Thread twp...@gmail.com
Is there a way to get an unchanging URL that always redirects to the latest major version of a package on pkg.go.dev? Right now, if I go to https://pkg.go.dev/$PACKAGE_NAME I get the documentation for either v0 or v1 of a package, which is out of date if there's a more recent major version. W

Re: [go-nuts] xml to json, parsing xml

2024-04-24 Thread twp...@gmail.com
You can parse XML and JSON quickly with these tools: https://github.com/twpayne/go-xmlstruct https://github.com/twpayne/go-jsonstruct They generate Go code that parses all the example XML and JSON files that you throw at them. Regards, Tom On Tuesday, April 23, 2024 at 9:17:33 PM UTC+2 Don Cal

[go-nuts] Re: Alternative text/template function libraries to github.com/Masterminds/sprig?

2024-05-20 Thread twp...@gmail.com
Just following up on this old message, there now seems to be at least: https://github.com/go-sprout/sprout https://github.com/chezmoi/templatefuncs Regards, Tom On Monday, January 9, 2023 at 8:53:41 PM UTC+1 Tom Payne wrote: > github.com/Masterminds/sprig is a popular library of template functi

[go-nuts] Re: Advancing the container/set design?

2024-07-01 Thread twp...@gmail.com
+1 on this. At the moment, every module that needs a set implementation ends up creating its own, either using map[T]struct{} or map[T]bool. Having a set implementation in the standard library would significantly increase operability between modules, even if the implementation is trivial. On

[go-nuts] Re: Advice on Using Pure Go with eBPF

2024-08-14 Thread twp...@gmail.com
For eBPF support in Go, see https://github.com/cilium/ebpf. AFAIK at the moment you can't compile Go to eBPF. The most promising approach is probably to adapt TinyGo to generate eBPF. There's an issue that's been open for three years with no activity: https://github.com/tinygo-org/tinygo/issues

Re: [go-nuts] How to define struct with defined properties that is also a map

2024-09-13 Thread twp...@gmail.com
Also, quick plug for https://github.com/twpayne/go-jsonstruct which will generate type-safe Go structs for you for all fields. Just throw a bunch of JIRA JSON responses at it. Regards, Tom On Friday, September 13, 2024 at 12:39:41 AM UTC+2 burak serdar wrote: > The current json implementation

[go-nuts] Re: ANN: Basic test impact analysis (benchmark shows avg 29% reduction in test execution time atm)

2024-09-13 Thread twp...@gmail.com
How does this interact with Go's existing test result cache, and specifically the invalidation of that cache? For example, go test tracks which external files are accessed by tests and will invalidate the test results cache when those files are modified. Will symflower test-runner also re-run

[go-nuts] Re: ANN: Basic test impact analysis (benchmark shows avg 29% reduction in test execution time atm)

2024-09-13 Thread twp...@gmail.com
Constructively, here's a great starting point for understanding go test's cache: https://github.com/golang/go/blob/f117d1c9b5951ab2456c1e512ac0423fcf3d7ada/src/cmd/go/internal/test/test.go#L1750-L1773 Regards, Tom On Friday, September 13, 2024 at 3:44:37 PM UTC+2 twp...@gmail

[go-nuts] go test cache: include umask as a test input for caching?

2024-09-13 Thread twp...@gmail.com
tl;dr: umask is a system-wide global that affects go tests and should be considered when validating go test's cache. Motivation: I'm the author of a popular open source project that writes files to the user's home dire

Re: [go-nuts] go test cache: include umask as a test input for caching?

2024-09-13 Thread twp...@gmail.com
Saturday, September 14, 2024 at 12:33:19 AM UTC+2 Ian Lance Taylor wrote: > On Fri, Sep 13, 2024 at 3:03 PM twp...@gmail.com wrote: > > > > tl;dr: umask is a system-wide global that affects go tests and should be > considered when validating go test's cache. > > > >

Re: [go-nuts] go test cache: include umask as a test input for caching?

2024-09-17 Thread twp...@gmail.com
ithin subtests? Note that subtests (like regular > tests) aren't run in parallel unless you explicitly call t.Parallel(). > > On Friday, September 13, 2024 at 6:35:15 PM UTC-4 twp...@gmail.com wrote: > >> > Personally, I would approach this kind of thing by writing a test tha

Re: [go-nuts] go test cache: include umask as a test input for caching?

2024-09-17 Thread twp...@gmail.com
different umask values is a different > problem from how to write unit tests that modify the umask value. At this > point it is unclear, at least to me, what problem you are trying to solve. > > On Tue, Sep 17, 2024 at 1:33 AM twp...@gmail.com wrote: > >> umask cannot be s

Re: [go-nuts] go test cache: include umask as a test input for caching?

2024-09-17 Thread twp...@gmail.com
On Tue, 17 Sept 2024 at 10:33, twp...@gmail.com wrote: umask cannot be set in subtests for two reasons: 1. It is a process-wide global variable stored by the operating system. Changing the umask in a test changes the umask for the entire process, i.e. it changes the umask for all tests. 2. I

Re: [go-nuts] go test cache: include umask as a test input for caching?

2024-09-17 Thread twp...@gmail.com
./... -count=1 The odds are that the tests will fail. However, I want to make go test cache's behavior more correct for a case where it is currently incorrect for no measurable performance penalty. What are the reasons for *not* doing this? On Tuesday 17 September 2024 at 11:25:40 UTC+1 tw

[go-nuts] Re: ANN: Priority channels: re-order values sent over a channel

2024-10-07 Thread twp...@gmail.com
cleanup in a defer at the top of this func > } > } > > ...and repeat such fixes for all other "raw" channel sends and receives. > > Regards, > Jason > > > > > On Sunday, October 6, 2024 at 1:42:14 AM UTC

[go-nuts] ANN: Priority channels: re-order values sent over a channel

2024-10-05 Thread twp...@gmail.com
Have you ever wanted a channel that partially sorts the values being passed through it? For example, you have some kind of work queue and you want to do the most important work first. Well, now you can! github.com/twpayne/go-heap.PriorityChannel

Re: [go-nuts] How to Implement Server-Sent Events in Go

2024-10-24 Thread twp...@gmail.com
I've had good success with Go/Server-Sent Events/HTMX/templ for cross-platform tools. Quick overview: * Go runs a webserver listening on localhost and opens the user's browser. * Front end is HTMX with HTML fragments served using the templ HTML templati

[go-nuts] Re: Should os.WriteFile call Sync()?

2025-04-20 Thread twp...@gmail.com
See also: https://github.com/google/renameio On Friday, April 18, 2025 at 1:31:52 PM UTC+2 Brian Candler wrote: > On Thursday, 17 April 2025 at 00:10:08 UTC+1 Karel Bílek wrote: > > I was quite surprised recently that, at least on linux, file.Close() does > not guarantee file.Sync(); in some edg

[go-nuts] Re: go mod:Force dependency to use newer major version of a module?

2025-04-20 Thread twp...@gmail.com
Thank you David and Joe for you replies. To close this issue for now: the conclusion is that there is no current solution. Regards, Tom On Monday, April 14, 2025 at 3:37:15 PM UTC+2 twp...@gmail.com wrote: > Hello, > > My project uses github.com/google/go-github/v71 and o

[go-nuts] go mod:Force dependency to use newer major version of a module?

2025-04-14 Thread twp...@gmail.com
Hello, My project uses github.com/google/go-github/v71 and one of its dependencies uses an earlier major version of the same module, github.com/google/go-github/v61. Consequently, the compiled binary contains both major versions of go-github, which bloats the binary by about 2MB. Is there a wa

[go-nuts] golang.org/x/crypto/x509roots/fallback: high, unskippable, init cost

2025-04-22 Thread twp...@gmail.com
tl;dr importing golang.org/x/crypto/x509roots/fallback adds ~8ms to the startup time of every program or library that imports it. I would like this cost to be zero and would be happy to contribute a fix. Running the following program: package main import _ "golang.org/x/crypto/x509roots

[go-nuts] Re: "gopkg.in/yaml.v2" package silently misparses file that is misformatted

2025-02-28 Thread twp...@gmail.com
I've recently switched to https://github.com/goccy/go-yaml and am very happy with it so far. I've not tried it on your use case. Regards, Tom On Friday, February 28, 2025 at 12:34:29 AM UTC+1 David Karr wrote: > I wrote some code to load a yaml file and do some work with the resulting > data.

[go-nuts] runtime.AddCleanup and C struct hierarchies: cleanup order?

2025-02-19 Thread twp...@gmail.com
The documentation for runtime.AddCleanup says: > There is no specified order in which cleanups will run. Given the following types: type Parent struct { parentResource int } type Child struct { parent *Parent childResource int } and the foll

Re: [go-nuts] runtime.AddCleanup and C struct hierarchies: cleanup order?

2025-02-19 Thread twp...@gmail.com
: > On Wed, Feb 19, 2025 at 1:12 PM twp...@gmail.com wrote: > > > > The documentation for runtime.AddCleanup says: > > > > > There is no specified order in which cleanups will run. > > > > Given the following types: > > > > type Parent struct {

[go-nuts] Re: golang.org/x/crypto/x509roots/fallback: high, unskippable, init cost

2025-05-12 Thread twp...@gmail.com
Gentle ping on this. If this is not wanted, then say. Otherwise, I will create an issue on https://github.com/golang/go to reach out to the relevant folk directly. Regards, Tom On Wednesday, April 23, 2025 at 1:11:22 AM UTC+2 twp...@gmail.com wrote: > tl;dr importing golang.org/x/cry