Re: [go-nuts] PDF to text

2025-01-23 Thread Duncan Harris
Amusingly we wrote our PDF table extractor largely in Go: https://pdftables.com/ It identifies tables and cells by looking at the statistical distribution of glyph boundaries on the pages rather than inferring anything from the way the text is logically grouped within the PDF. There are many ap

Re: [go-nuts] Re: Range over int

2024-02-23 Thread Duncan Harris
I made some changes to use range over int in our code base and was pleasantly surprised with the improvement in readability. We had quite a few instances where the number of iterations involved a function call which we don't want to repeat: - for i, n := 0, f(); i < n; i++ { + for i := range f(

[go-nuts] Re: Measuring the total time of serving a request

2023-11-20 Thread Duncan Harris
I would argue that it doesn't matter. The buffers in the operating system can often substantially exceed the size of those in the Go runtime. Try using an artificially slow reader (e.g. curl --limit-rate) and you should see. Why do you care about buffering in Go vs the OS? On Sunday, 19 November

Re: [go-nuts] Equivalence of types declared with equals

2023-06-04 Thread Duncan Harris
gt;> See https://go.dev/ref/spec#Type_definitions and >> https://go.dev/ref/spec#Type_identity. In particular this statement: "The >> new type is called a *defined type*. It is different >> <https://go.dev/ref/spec#Type_identity> from any other type, including >&g

[go-nuts] Equivalence of types declared with equals

2023-06-03 Thread Duncan Harris
Why does this not work? https://go.dev/play/p/dodUj441xJS Produces the rather strange error message: ./prog.go:7:6: cannot use []t{…} (value of type []struct{f string}) as []struct{f string} value in argument to m.F -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: Best way to mark unused parameters/error values reported by linter

2023-03-07 Thread Duncan Harris
What is the reason for including the unused parameter in the function signature? If it was a method and the reason was to comply with an interface signature then you can assert the interface to get unparam to ignore: var _ InterfaceType = (*MyType)(nil) or if not a pointer receiver var _ Inter

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

2023-02-06 Thread Duncan Harris
Do you really need the branch? You get the commit hash for free since Go 1.18 : https://tip.golang.org/doc/go1.18#go-version You can see the embedded version information with: go version -m On Monday, 6 February 2023 at 17:33:53 UTC burker...@gmail.com wrote: > You can use go:generate and go:e

[go-nuts] go install of forked repo

2022-12-03 Thread Duncan Harris
This seems a noddy question but can't easily find an answer with Google apparently. I may have lost the plot :-) There is a repo which contains source for a go executable that I want to use. Normally I install this with: go install original.domain/path@latest I want to fork that repo and make so

Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-09 Thread Duncan Harris
> Interestingly, I couldn't put the asStr() code in the String() function since doing so produced this error: > > invalid operation: cannot use type assertion on type parameter value element (variable of type T constrained by comparable) You need to convert to "any": https://go.dev/play/p/1pMhs