Re: [go-nuts] Using errors.As error-prone

2025-02-14 Thread 'Brian Candler' via golang-nuts
> That is, functions never return `*os.PathError` or the like ... which of course is a good thing, as nil pointers and nil interfaces are different. This is something that confused me when I first came to Go: https://go.dev/play/p/R-oZwlqimA2 Hence errors are the exception to the general rule o

Re: [go-nuts] Using errors.As error-prone

2025-02-12 Thread 'Brian Candler' via golang-nuts
It's also consistent with the common idiom of errors.New("foo") which returns a pointer (to an unexported type) - although this doesn't appear to be documented, except that "Each call to New returns a distinct error value even if the text is identical" On Wednesday, 12 February 2025 at 09:06:08

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-02-09 Thread 'Brian Candler' via golang-nuts
, err := fmt.Fscanln(r, &x, &y) >> fmt.Println(n, err, x, y, len(y)) // 2 xxx yyy 3 >> } >> { >> var r = strings.NewReader("xxx yyy \n") >> var x, y string >> n, err := fmt.Fscanln(r, &x, &y) >> fmt.Println(n, err, x, y, len(y)) //

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-30 Thread 'Brian Candler' via golang-nuts
I guess not, but since it uses a plain io.Reader which doesn't support peek or pushback, I can't think of any other behavior which is possible. On Thursday, 30 January 2025 at 19:27:51 UTC tapi...@gmail.com wrote: > On Tuesday, January 28, 2025 at 7:07:15 PM UTC+8 Brian Candler wro

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-28 Thread 'Brian Candler' via golang-nuts
> The documentation tells that Fscanln() is similar to Fscan(), my test shows that it isn't true for some cases. "similar" does not mean "the same as". Fscanln chomps the fields given, then chomps the next character. If the next character is newline, it's happy. If the next character is not a

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-14 Thread 'Brian Candler' via golang-nuts
confirm it by multiplying the length of the input by 3/4 % echo -n "Qm9uam91ciwgam95ZXV4IGxpb24K" | wc -c 28 28*3/4 = 21 B o n j o u r , _ j o y e u x _ l i o n \n On Tuesday, 14 January 2025 at 10:10:22 UTC Brian Candler wrote: > Sorry ignore that, I hadn't checked your

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-14 Thread 'Brian Candler' via golang-nuts
Sorry ignore that, I hadn't checked your playground link. On Tuesday, 14 January 2025 at 10:07:53 UTC Brian Candler wrote: > > AS I wrote earlier, I'm trying to avoid reading the entire email part > into memory to discover if I should use base64.StdEncoding or > base64.Ra

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-14 Thread 'Brian Candler' via golang-nuts
> AS I wrote earlier, I'm trying to avoid reading the entire email part into memory to discover if I should use base64.StdEncoding or base64.RawStdEncoding. As I asked before, why would you ever need to use RawStdEncoding? It just means the MIME part was invalid, most likely corrupted/truncated

[go-nuts] Re: Efficiently switch io.Reader to another decoder on error

2025-01-13 Thread 'Brian Candler' via golang-nuts
> I'm looking to develop an alternative to an existing piece of code that reads email parts into byte slices and then returns these after decoding Aside: are you actually seeing invalid (unpadded) base64-encoded MIME parts in the wild? Since a padded base64-encoded block will always be a multip

Re: [go-nuts] Golang ORM Performances

2025-01-11 Thread 'Brian Candler' via golang-nuts
endtoend/testdata/ddl_create_procedure/postgresql/pgx/v5/go/query.sql.go On Friday, 10 January 2025 at 13:26:22 UTC Rory Campbell-Lange wrote: > On 10/01/25, 'Brian Candler' via golang-nuts (golan...@googlegroups.com) > wrote: > > On Thursday, 9 January 2025 at 19

Re: [go-nuts] Golang ORM Performances

2025-01-10 Thread 'Brian Candler' via golang-nuts
On Thursday, 9 January 2025 at 19:49:23 UTC Roland Müller wrote: Reason for that is that doing all DB access methods in the application language (Go or Java) tends to a codebase where you have SQL code snippets scattered over in your code. When the application now grows it will be more and more

Re: [go-nuts] Strip HTML comments before processing template

2025-01-02 Thread 'Brian Candler' via golang-nuts
On Wednesday, 1 January 2025 at 21:44:25 UTC Mike Schinkel wrote: If it stripped HTML comments then it would not be possible to generate output that contains wanted comments. But it *does* strip comments, doesn't it? https://go.dev/play/p/0EChuy5CjyH -- You received this message because you a

[go-nuts] Re: How to manage database schemas

2024-12-22 Thread 'Brian Candler' via golang-nuts
> I heard about SQLc a lot, but my question is how can I use it to manage my database schemas with it, is it event possible? sqlc works with a bunch of different migration tools: https://docs.sqlc.dev/en/latest/howto/ddl.html#handling-sql-migrations The one called "tern" is postgres-specific but

Re: [go-nuts] Golang ORM Performances

2024-12-22 Thread 'Brian Candler' via golang-nuts
n in prod? > > it feels like as soon as. you try to add dynamic queries SQLC appeal > dwindles. That being said, for simple queries SQLC is awesome. <3 > > > > On Thu, Dec 19, 2024 at 9:17 AM Mike Schinkel > wrote: > >> Hi Bhavesh, >> >> I am also no

[go-nuts] Re: Working with release candidates

2024-12-20 Thread &#x27;Brian Candler' via golang-nuts
> Can someone explain how to disable this? I never want to download anything at compile time. go env -w GOTOOLCHAIN=local On Friday, 20 December 2024 at 15:07:43 UTC Jeffery Carr wrote: > I also have noticed this new 'toolchain' option. I'm a bit confused about > how it works. > > "This automa

[go-nuts] Re: Golang ORM Performances

2024-12-19 Thread &#x27;Brian Candler' via golang-nuts
I am not a fan of ORMs. Application performance problems are usually down to poorly formed SQL queries (and/or lack of supporting indexes), which ORMs can mask or amplify. For an alternative approach, have a look at https://github.com/sqlc-dev/sqlc In short, you write the set of SQL queries to

[go-nuts] Re: The possibilty run go source code as real scripts

2024-11-23 Thread &#x27;Brian Candler' via golang-nuts
Have you looked at this? https://github.com/traefik/yaegi?tab=readme-ov-file#as-a-command-line-interpreter It supports shebang execution of scripts, and it seems to be maintained: *"Support the latest 2 major releases of Go (Go 1.21 and Go 1.22)"* -- You received this message because you are s

[go-nuts] Re: no direct write to a complex types components?

2024-11-09 Thread &#x27;Brian Candler' via golang-nuts
On Saturday 9 November 2024 at 00:25:21 UTC simon place wrote: but whereas you can read a component... real com.:=Real(cmplx) imaginary com.:=Imag(cmplx) i can't see any way to write to a component. That's because Complex numbers are immutable - just like strings, and regular numbers for that

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

2024-10-23 Thread Brian Hatfield
I don't think it's quite so binary. Websockets are a lot more complex, require more sophisticated endpoints and load balancing. SSE has fine browser support in 2024, minus the ability to set auth headers. I think for cases with unidirectional communication, SSE is a choice worth evaluating. On Wed

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

2024-10-23 Thread Brian Hatfield
Here's a toy example on how to implement it: https://github.com/bmhatfield/sse On Wed, Oct 23, 2024 at 9:54 AM Alex Pliutau wrote: > Does anyone use Server-Sent Events in their projects? If yes, for which > use cases? > https://youtu.be/nvijc5J-JAQ > > -- > You received this message because you

[go-nuts] Re: Non-blocking Read from StdoutPipe and StderrPipe

2024-10-15 Thread &#x27;Brian Candler' via golang-nuts
On Monday 14 October 2024 at 22:57:07 UTC+1 Peter Bočan wrote: What is the recommended way of reading whatever is on the buffer and return back without blocking? If you just want to poll, and get whatever data is available: set a deadline of "just after now", and read. https://go.dev/play/p/bF

Re: [go-nuts] Re: [ANN] tk9.0: The CGo-free, cross platform GUI toolkit for Go

2024-10-14 Thread &#x27;Brian Candler' via golang-nuts
Or it could be like https://pkg.go.dev/modernc.org/sqlite, which took the Sqlite C source code and transpiled it into pure Go. Refs: https://twitter.com/bradfitz/status/855271867162083329?lang=en https://groups.google.com/g/golang-nuts/c/QDEczMhlQBU/m/4lCn2kP0AwAJ On Monday 14 October 2024 at 18

Re: [go-nuts] Using structs, pointers, and maps

2024-10-09 Thread &#x27;Brian Candler' via golang-nuts
On Tuesday 8 October 2024 at 07:37:25 UTC+1 Axel Wagner wrote: the only one on the "mixing receiver kinds is sometimes necessary, so we shouldn't caution against it" side of the table To me this sounds like a false dichotomy. It can be good general good-practice advice to avoid mixing pointer

[go-nuts] Re: Profiling the `go` tool itself?

2024-10-02 Thread &#x27;Brian Candler' via golang-nuts
On Wednesday 2 October 2024 at 18:11:10 UTC+1 opennota wrote: Cold-start builds are slow af on my machine (think tens of minutes), and have been like that since around Go 1.20. Have you ruled out that it's not anything to do with the automatic fetching of toolchains, introduced in 1.21 I think

Re: [go-nuts] [ANN] tk9.0: The CGo-free, cross platform GUI toolkit for Go

2024-09-28 Thread &#x27;Brian Candler' via golang-nuts
Aside: on front page: "Viewing this on go.pkg.dev?" Actually I was viewing it on pkg.go.dev :-) On Saturday 28 September 2024 at 19:29:50 UTC+1 Robert Engels wrote: > Very cool! > > > On Sep 28, 2024, at 1:04 PM, Jan Mercl <0xj...@gmail.com> wrote: > > > > http://modernc.org/tk9.0 > > > > --

[go-nuts] Re: I want to know the reason behind slices.Clone using append s[:0:0]

2024-09-26 Thread &#x27;Brian Candler' via golang-nuts
quot;. On Thursday 26 September 2024 at 14:55:22 UTC+1 Brian Candler wrote: > > I want to know the reason behind the decision of using *append(s[:0:0], > s...)* over the previous code > > It would be helpful to identify specifically the "previous code" you're > c

[go-nuts] Re: I want to know the reason behind slices.Clone using append s[:0:0]

2024-09-26 Thread &#x27;Brian Candler' via golang-nuts
> I want to know the reason behind the decision of using *append(s[:0:0], s...)* over the previous code It would be helpful to identify specifically the "previous code" you're comparing against. Looking in git history I find this commit from about a year ago: commit b581e447394b4ba7a08ea64b21

[go-nuts] Re: os.Exit doesn't exit the program with the specified error code as expected

2024-09-23 Thread &#x27;Brian Candler' via golang-nuts
What makes you think that the line which calls os.Exit(1) is being reached? What are your test arguments to the program? On Monday 23 September 2024 at 14:42:31 UTC+1 Maisa Unbelievable wrote: > Hello there! I don't quiet understand why *os.Exit* doesn't terminate my > program according to its d

[go-nuts] Re: Can a golang program be compiled to run with only ONE goroutine ?

2024-09-10 Thread &#x27;Brian Candler' via golang-nuts
What's your use case? Would TinyGo be sufficient for your needs? https://tinygo.org/docs/guides/tips-n-tricks/ "TinyGo code runs on a single core, in a single thread (think GOMAXPROCS=1)" On Tuesday 10 September 2024 at 14:54:56 UTC+1 Karolina GORNA wrote: > Hello, > > Maybe the question has alr

[go-nuts] Re: execution of a go program

2024-08-22 Thread &#x27;Brian Candler' via golang-nuts
It's easy enough to demonstrate: https://go.dev/play/p/dvTJL5_UJrs You have a process with threads where goroutines run. When that process dies, all goroutines die too. They cannot live beyond, or independently from, the main process. On Thursday 22 August 2024 at 14:50:37 UTC+1 Adithyan Unni w

[go-nuts] Re: segmention fault while upgrading from 1.20.6 to 1.22.3

2024-08-21 Thread &#x27;Brian Candler' via golang-nuts
> /root/go/bin/wire-v0.5.0 gen -tags oss ./pkg/server Is it running the binary "/root/go/bin/wire-v0.5.0 " at this point? If so, it would seem to be a bug in that application. Debug as you would any other go program. In particular, try running it under the race detector. You don't give any ref

[go-nuts] Re: how to attach the pkg revision during go install

2024-08-20 Thread &#x27;Brian Candler' via golang-nuts
As a reference, you could look at how prometheus does it: % go install github.com/prometheus/prometheus/cmd/prometheus % ~/go/bin/prometheus --version prometheus, version (branch: , revision: b914a9b580abd7bb7e879602c17fea0e06fd0266) ... I know it uses a build utility (promu) to embed the info

[go-nuts] Re: About code under the examples folder and lib module

2024-08-17 Thread &#x27;Brian Candler' via golang-nuts
It's only going to compile/link packages which are referenced by an "import" statement (recursively). On Saturday 17 August 2024 at 10:36:11 UTC+6 Tong Sun wrote: > Hi, > > when providing a lib/module, would sample code under the `examples` folder > be considered/linked as part of the module? I

Re: [go-nuts] Imitating tuple in golang

2024-08-11 Thread &#x27;Brian Candler' via golang-nuts
a function for case (1), or would you have to do it yourself using e.g. unsafe.SliceData? Clearly case (2) is supported via bytes.Equal, slices.Equal etc. On Sunday 11 August 2024 at 05:08:26 UTC+6 Ian Lance Taylor wrote: > On Fri, Aug 9, 2024 at 9:03 PM 'Brian Candler' via gol

Re: [go-nuts] Imitating tuple in golang

2024-08-09 Thread &#x27;Brian Candler' via golang-nuts
On Friday 9 August 2024 at 06:19:22 UTC+6 Jolyon Direnko-Smith wrote: Second, you don't need to implement a custom == operator to compare custom struct types; the implementation of == in Golang already covers the comparison of structured value types in a logical, intuitive and type-safe manner.

[go-nuts] Re: Optimization Question: Convert Array to Slice without Allocation

2024-07-31 Thread &#x27;Brian Candler' via golang-nuts
On Tuesday 30 July 2024 at 21:54:32 UTC+1 William Gilmore wrote: func DCT2DFast8(in []float64) (out [64]) {...} - Optimized static code, 0 allocations when called directly. See following benchmark. I am guessing return should be something like *out [64]float64* ? Ideally, I would like for

Re: [go-nuts] this code sometimes hangs

2024-07-20 Thread &#x27;Brian Candler' via golang-nuts
This video is well worth watching, pausing and rewinding as required. It's Bryan C. Mills "Rethinking Classical Concurrency Patterns": https://www.youtube.com/watch?v=5zXAHh5tJqQ It shows patterns which are tricky to implement correctly with condition variables and semaphores can be cleanly impl

Re: [go-nuts] Does data race with only multiple goroutine parallel i=1 have an impact on the execution results?

2024-07-07 Thread &#x27;Brian Candler' via golang-nuts
The question seems to be: "I know this is a data race, but isn't this a *safe* data race?" To which the answer should be: "There are no safe data races". https://docs.google.com/document/d/1WAT22FtFdMt43i3O8YrnlQTNTzZ3IoJBtu3P2DNRytg/ # was previously: https://software.intel.com/en-us/blogs/20

[go-nuts] Re: More excellent work by the Go team!

2024-06-21 Thread &#x27;Brian Candler' via golang-nuts
> 4775.994 ± 13310.309 Those are pretty wide error bars though... On Friday 21 June 2024 at 17:15:05 UTC+1 Robert Engels wrote: > I had the opportunity to revisit my interface dispatch benchmark ( > https://github.com/robaho/go-dispatch-test). > > Previously, the dispatching using pointer receiv

[go-nuts] Re: Comparison of pointers to distinct zero-sized variables

2024-06-19 Thread &#x27;Brian Candler' via golang-nuts
There was a similar discussion here: https://groups.google.com/g/golang-nuts/c/JBVqWYFdtC4/m/VJC2OLJcAQAJ It is very sensitive to exactly how the variables are used. For example, if you replace your println() with fmt.Println() then you get a different answer. https://go.dev/play/p/D5z4q6iCTke

Re: [go-nuts] Re: Call the .net dlls into the golang

2024-05-23 Thread &#x27;Brian Candler' via golang-nuts
"try building at the command line" That's your clue. You'll most likely get a meaningful error message on stderr, which your IDE is hiding. On Thursday 23 May 2024 at 13:47:10 UTC+1 Pavan Kumar A R wrote: > Hello , > > I am try to call the c program in the golang , but i am getting the issue

Re: [go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread &#x27;Brian Candler' via golang-nuts
* Start in an empty directory * Run "go mod init example" * Create your main.go with that import statement in it * Run: go mod tidy go run . On Wednesday 22 May 2024 at 16:26:54 UTC+1 Kenneth Miller wrote: > I tried that, same error > > On Wednesday, May 22, 2024 at 9:1

Re: [go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread &#x27;Brian Candler' via golang-nuts
It's because the name of the module is "github.com/aclements/go-z3/z3", not "z3" Only packages in the standard library have short names, like "fmt", "strings" etc. On Wednesday 22 May 2024 at 15:46:30 UTC+1 robert engels wrote: > If it is your own code, you have to use > > import “github.com/a

[go-nuts] Re: var errors stdlib

2024-05-10 Thread &#x27;Brian Candler' via golang-nuts
On Friday 10 May 2024 at 17:03:46 UTC+1 Sebastian Bogan wrote: Would something like the following work (and be less risky)?: type ConstError string func (e ConstError) Error() string { return string(e) } const ErrNotExist = ConstError("file does not exist") If you compare an error v

[go-nuts] Re: Slice conversion function not working on big endian platform

2024-05-08 Thread &#x27;Brian Candler' via golang-nuts
That code doesn't even compile in go 1.22 or go.1.21: https://go.dev/play/p/mPCBUQizSVo ./prog.go:20:14: cannot convert unsafe.Pointer(s) (value of type unsafe.Pointer) to type []To What's the underlying requirement? In the test case it looks like you want to take a slice of int32's, in whatever

[go-nuts] Re: tuples! tuples! tuples!

2024-04-28 Thread &#x27;Brian Candler' via golang-nuts
A few questions (I'm ignoring generics for now, and have not cross-referenced the other proposals). 1. Is it possible to access the n'th element of an implicitly typed tuple? More generally, how do you unpack such a tuple - other than by assigning to a compatible named tuple type? 2. How does

[go-nuts] Re: net/http Http Server - fail with Proxy Protocol header (v1/v2)

2024-04-26 Thread &#x27;Brian Candler' via golang-nuts
ble > from TLS. > > I agree with all other points, but wanted to mention that. 🙂 > > -eli > > > On Monday, April 15, 2024 at 4:43:50 PM UTC-4 Brian Candler wrote: > > > My point is that a http server that is using the standard library always > reply with a

[go-nuts] Re: net/http Http Server - fail with Proxy Protocol header (v1/v2)

2024-04-15 Thread &#x27;Brian Candler' via golang-nuts
> If someone needs to parse the proxy protocol, it's fine to implement or > add a 3rd party lib, but I think the "default" should just work. > > Brian Candler schrieb am Montag, 15. April 2024 um 20:41:50 UTC+2: > >> Your answer was given here: >> https:

[go-nuts] Re: net/http Http Server - fail with Proxy Protocol header (v1/v2)

2024-04-15 Thread &#x27;Brian Candler' via golang-nuts
Your answer was given here: https://github.com/golang/go/issues/65078#issuecomment-1890419683 In other words: - net/http handles HTTP - go-proxyprotocol handles the proxy protocol - you combine the two to get the behaviour you want Orthogonal pieces which handle their own responsibilities are a G

Re: [go-nuts] Re: <-ctx.Done() panic - link injecting bot?

2024-03-30 Thread &#x27;Brian Candler' via golang-nuts
I clicked the "Report message" button for each of them, selecting type of abuse "Spam". Whether anyone reads these is doubtful though. The first spam was on 3 Jan 2024 and I reported it straight away; it hasn't stopped the new ones coming through. On Saturday 30 March 2024 at 10:21:18 UTC Steve

Re: [go-nuts] Nil pointer panic that should be impossible

2024-03-25 Thread &#x27;Brian Candler' via golang-nuts
And as Axel's own reproducer shows, even having two threads reading and writing the same *variable* which points to a string can result in indeterminate behaviour, since a string is really a struct containing two parts (a pointer and a len). You're not mutating the string itself, but you are u

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread &#x27;Brian Candler' via golang-nuts
I got the impression the proposal was motivated by scalars that did not currently allow `nil` values Under the heading "Alternatives and why they're bad" he describes some ways this is currently dealt with - such as the common idiom of returning or passing a pointer to a value, instead of a

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread &#x27;Brian Candler' via golang-nuts
On Wednesday 20 March 2024 at 09:01:43 UTC Mike Schinkel wrote: Your comments made me go back and read the whole thing, but I was unable to find a list of enumerated objectives, and I did not find the text you quoted. Did I miss it somehow? It's in the very first post that opened this thread,

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread &#x27;Brian Candler' via golang-nuts
When you say "var x NillableUint8" then you've just declared a variable of an interface type, and interface types are already nilable, so there's no need for "| nil" in the type! https://go.dev/play/p/f54akG65qJ3 https://go.dev/play/p/Jmtlta0h9m9 // generic version It's a perfectly valid way

Re: [go-nuts] Nillable basic types?

2024-03-18 Thread &#x27;Brian Candler' via golang-nuts
I like Go because it's relatively simple and low-level, like C, except with things like garbage collection and channels integrated. If Go were to have "| nil" types then the internal representation of such variables would have to be something like this: type Maybe[T any] struct { Value T IsSet

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Brian Hatfield
Client.GetChild() must return GetChilder, not Child. On Wed, Mar 13, 2024 at 10:02 AM Rodrigo Araujo wrote: > Given the code bellow, I'm trying to keep my packages completely > separated, without knowing each other, but the code doesn't work. I just > can get it running when I define (or use) an

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-09 Thread &#x27;Brian Candler' via golang-nuts
Perhaps it would be helpful to give some concrete figures for the real-world application. "the response time of Go API is higher than PHP" - how much? Are we talking, say, 1.2ms versus 1ms? Or 10ms versus 1ms? Is this testing between a client and server adjacent on the same LAN, or is the serve

[go-nuts] Re: How to add labels to Go runtime prometheus metrics?

2024-03-06 Thread &#x27;Brian Candler' via golang-nuts
The server name will be added by Prometheus itself as an "instance" label for each target being scraped (or you can manually set the instance label for each target), so in general what you're asking is not necessary. None of the standard Prometheus exporters include a label for the hostname (e.

Re: [go-nuts] Enums, Go1 and proposals

2024-03-04 Thread &#x27;Brian Candler' via golang-nuts
On Monday 4 March 2024 at 15:18:05 UTC Jeremy French wrote: What I find valuable is to be able to accept an enum as a parameter to a function, and know that it will be one of several approved values (e.g. month of the year) ISTM all that's needed is to have a way to create a named type which c

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-27 Thread &#x27;Brian Candler' via golang-nuts
> let's consider the two possible definitions: > > 1. Pointers to distinct zero-size variables are equal: [...] > 2. Pointers to distinct zero-size variables are not equal: Another possibility: 3. Equality comparisons between pointers to zero-size variables are forbidden at compile time. 3a. If

Re: [go-nuts] help

2024-02-18 Thread &#x27;Brian Candler' via golang-nuts
Your code includes this line: log.Println("DATABASE_URL:", os.Getenv("DATABASE_URL")) What does the log message actually show? This will confirm whether the environment variable is being passed correctly or not. I note you are using a different YAML structure for "environment" under go_app than

[go-nuts] Re: Trying to understand aversion to main package

2024-02-15 Thread &#x27;Brian Candler' via golang-nuts
On Thursday 15 February 2024 at 00:08:44 UTC Jerry Londergaard wrote: If code is outside of the main function but still in the main package, it seems its testable like other functions? Yes indeed. I suspect though if one is putting tests in package main_test, then I guess you can't import t

Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread &#x27;Brian Candler' via golang-nuts
Have you tried running your entire code under the race detector? https://go.dev/blog/race-detector On Wednesday 14 February 2024 at 06:02:02 UTC Kurtis Rader wrote: > Maybe provide a minimal reproducible example ( > https://stackoverflow.com/help/minimal-reproducible-example)? > > While it is the

[go-nuts] Re: KeepAlive with net.Listen

2024-02-11 Thread &#x27;Brian Candler' via golang-nuts
s so much sense. So should I long-poll until next request > line comes or keep-alive times out? Is there a better way to detect > incoming requests and then maybe awake the goroutine using channels? > On Saturday, February 10, 2024 at 1:52:23 AM UTC-8 Brian Candler wrote: > >> H

[go-nuts] Re: KeepAlive with net.Listen

2024-02-10 Thread &#x27;Brian Candler' via golang-nuts
Handling keep-alives on the *server* side doesn't require any sort of connection pool. Just create one goroutine for each incoming TCP connection, and once you've handled one request, loop around, waiting for another request on the same connection. (That's assuming the client does request use o

Re: [go-nuts] Opening network connections blocks system thread

2024-02-10 Thread &#x27;Brian Candler' via golang-nuts
I can't see how a large number of waiting goroutines would cause an increase in the number of OS threads, which was the OP's original problem (hitting the 10,000 thread limit) What the OP is implying - but we have not seen good evidence for yet - is that in some circumstances a non-blocking con

[go-nuts] Re: Go 1.22 binary size improvements?

2024-02-09 Thread &#x27;Brian Candler' via golang-nuts
, current version 0.0.0) > /System/Library/Frameworks/Security.framework/Versions/A/Security > (compatibility version 0.0.0, current version 0.0.0) > > On Friday, February 9, 2024 at 2:22:36 PM UTC+1 Brian Candler wrote: > >> Have you at any point set CGO_ENABLED=0 ? >> &

[go-nuts] Re: Go 1.22 binary size improvements?

2024-02-09 Thread &#x27;Brian Candler' via golang-nuts
Have you at any point set CGO_ENABLED=0 ? What does "ldd /path/to/binary" show on both the old (larger) and new (smaller) binaries? Maybe one is dynamically linked and the other statically linked? -- You received this message because you are subscribed to the Google Groups "golang-nuts" grou

[go-nuts] Re: Go 1.22.0: Alpine: go test with coverage works but returns exit status 1

2024-02-08 Thread &#x27;Brian Candler' via golang-nuts
look like the underlying errors causing the exit code 1. But it works fine for me under both Linux and macOS, as long as I have "go 1.22.0" in go.mod. Maybe someone who knows more about Windows can help? On Thursday 8 February 2024 at 17:03:18 UTC Martin Schallnahs wrote: > Hi Bria

[go-nuts] Re: Go 1.22.0: Alpine: go test with coverage works but returns exit status 1

2024-02-08 Thread &#x27;Brian Candler' via golang-nuts
, when go.mod used to contain "go X.Y" and it was invalid to put "go X.Y.Z". Now that appears to have swapped around <https://github.com/golang/go/issues/62278#issuecomment-1698829945>. On Thursday 8 February 2024 at 08:30:25 UTC Brian Candler wrote: > Is i

[go-nuts] Re: Go 1.22.0: Alpine: go test with coverage works but returns exit status 1

2024-02-08 Thread &#x27;Brian Candler' via golang-nuts
Is it a bug or exepected behaviour? If a test fails, I would expect it to terminate with an error (exit code 1 in this case). If I run your reproducer locally (not in Docker) with the modified TestHelloer, it works fine(*) and gives me an exit code of 0: % go test -v ./... -coverprofile=cov

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread &#x27;Brian Candler' via golang-nuts
But the main point is, the canonical version published at https://go.dev/ref/spec is still from Aug 2, 2023 On Wednesday 7 February 2024 at 12:02:28 UTC Rob Pike wrote: > Ha ha, someone forgot to change the year. It should read Jan 30, 2024. > > That's confusing. > > -rob > > > On Wed, Feb 7, 20

[go-nuts] Re: Do we need to call multipart.Part.Close

2024-02-06 Thread &#x27;Brian Candler' via golang-nuts
y guarantee (unless it was fundamental to a security issue, and even then I'd expect it to allow existing use cases). On Tuesday 6 February 2024 at 14:29:07 UTC Pedro Luis Guzmán Hernández wrote: > Thanks Brian. That is an implementation detail though, so relying on it > with no mentio

[go-nuts] Re: Do we need to call multipart.Part.Close

2024-02-06 Thread &#x27;Brian Candler' via golang-nuts
https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/mime/multipart/multipart.go;l=325 All it does is read all the remainder of the part to io.Discard. So if you're sure you've read each part before moving onto the next one, it looks like you should be good. On Tuesday 6 February 2024 a

Re: [go-nuts] Re: snprintf() in Go with at most constant memory requirement difference than snprintf(3)?

2024-02-06 Thread &#x27;Brian Candler' via golang-nuts
> Thanks! In addition to that, It also helps with code with upper limit > memory-requirement, which fmt.Sprintf() can't. If you're processing data from untrusted sources, then you probably ought to validate it first. > How to use a limiting > io.Writer with fmt.Sprintf()? How would this limit fm

[go-nuts] Re: snprintf() in Go with at most constant memory requirement difference than snprintf(3)?

2024-02-06 Thread &#x27;Brian Candler' via golang-nuts
The C functions are mainly there to prevent overrunning already-allocated buffers, which isn't an issue with Go. You could truncate the response: a := fmt.Sprintf("%s", "Blah blah blah")[0:10] You could use suitable precision specifiers: a := fmt.Sprintf("%.10s", "Blah blah blah") You

[go-nuts] Re: Golang formating of alternate form with zero padding

2024-02-03 Thread &#x27;Brian Candler' via golang-nuts
Admittedly, C and Python work the same way, which is different to Go. #include int main(void) { printf("%07x\n", 42); printf("%0#7x\n", 42); printf("0x%07x\n", 42); return 0; } // Output 02a 0x0002a 0x02a On Wednesday 31 January 2024 at 13

[go-nuts] Re: Golang formating of alternate form with zero padding

2024-01-31 Thread &#x27;Brian Candler' via golang-nuts
https://pkg.go.dev/fmt#hdr-Printing The '#' means you want the alternate format with the 0x prepended, and the '7' means you want the number itself padded to 7 digits x := fmt.Sprintf("%07x", 42) // 02a y := fmt.Sprintf("%0#7x", 42) // 0x02a z := fmt.Sprintf("0x%07x", 42) // 0x000

Re: [go-nuts] Re: Is encoding/json POSIX compatible?

2024-01-30 Thread &#x27;Brian Candler' via golang-nuts
with "incomplete" lines (3.195), but not arbitrarily long ones. On Tuesday 30 January 2024 at 15:20:00 UTC Javier Marti wrote: > So, as per the link that I sent, a json file is not a text file, right? is > just a file, I want to have this clear > > > thanks > > O

[go-nuts] Re: Is encoding/json POSIX compatible?

2024-01-30 Thread &#x27;Brian Candler' via golang-nuts
The JSON spec does not require any whitespace after the object, newline or otherwise. And POSIX does not require that files end with a newline. Maybe you are thinking of another spec, like https://jsonlines.org/ - but that's not part of JSON. On Tuesday 30 January 2024 at 14:16:35 UTC Xabi Mart

[go-nuts] Re: Rendering fonts in Go

2024-01-12 Thread &#x27;Brian Candler' via golang-nuts
At worst, it may possible to compile C into Go. It sounds mad, but I believe SQLite has been ported to pure Go this way. https://pkg.go.dev/modernc.org/sqlite https://twitter.com/bradfitz/status/855271867162083329?lang=en https://groups.google.com/g/golang-nuts/c/QDEczMhlQBU/m/4lCn2kP0AwAJ https:

[go-nuts] Re: mmapping over Go heap

2024-01-10 Thread &#x27;Brian Candler' via golang-nuts
> accessing it after munmap leads to SIGSEGV or worse There must be a hundred different ways you can make a Go program segfault, and this doesn't sound any worse that the rest of them. Besides, unless the GC is changed to handle mmap regions differently, I think you would have the problem the o

[go-nuts] Cipher suite oddity

2024-01-09 Thread &#x27;Brian Candler' via golang-nuts
Something just pointed out to me(*) that I don't understand: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA is in tls.CipherSuites() TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 is in tls.InsecureCipherSuites() Why is the SHA256 variant consi

Re: [go-nuts] Re: [RFC] Syntactic Dissonance

2024-01-06 Thread &#x27;Brian Candler' via golang-nuts
Full explanation here: https://blog.merovius.de/posts/2018-06-03-why-doesnt-go-have-variance-in/ On Saturday 6 January 2024 at 11:55:27 UTC John Pritchard wrote: > Hi, > > Thinking about types and their conception, I could avoid the type > assertion boilerplate and rationalize the type membershi

[go-nuts] Re: <-ctx.Done() panic

2024-01-03 Thread &#x27;Brian Candler' via golang-nuts
Panics can be caused by all sorts of things, but concurrency issues are a big one. Have you tried running your code under the race detector? https://go.dev/blog/race-detector On Wednesday 3 January 2024 at 10:57:49 UTC cheng dong wrote: > i have a program paniced with > > ``` > runtime.deferCal

[go-nuts] Re: How to get net.Conn in rpc function in net/rpc

2023-12-28 Thread &#x27;Brian Candler' via golang-nuts
What do you mean by "Real IP" and in particular how does it differ from the TCP source address? If the client is behind a NAT, then (a) you won't know the client's real IP unless they tell it to you (and you trust what they say), and (b) you won't be able to connect to that address anyway. If y

[go-nuts] Re: regexp docs for 'Index' ?

2023-12-14 Thread &#x27;Brian Candler' via golang-nuts
e input, while the "n" > indexes are actually the values of the submatches, not the indexes. I still > think it's confusing, but makes more sense when I write it like this: > https://go.dev/play/p/SHl_aSU3kPZ > > On Thursday 14 December 2023 at 09:06:00 UTC Brian

[go-nuts] Re: regexp docs for 'Index' ?

2023-12-14 Thread &#x27;Brian Candler' via golang-nuts
[a:b] gives you the elements from a to b-1 inclusive. So if you want the pair at position x, it has to be [x:x+2] https://go.dev/play/p/3nvEfOjdfnj On Thursday 14 December 2023 at 08:38:57 UTC Peter Galbavy wrote: > I noticed today that the regexp docs read: > > If 'Index' is present, matches a

[go-nuts] Re: detecting deleted file that is still open and appending without error in Go?

2023-12-11 Thread &#x27;Brian Candler' via golang-nuts
On Sunday 10 December 2023 at 16:41:00 UTC Jason E. Aten wrote: My question is: is there a way to have the Go process detect if the file it is writing to has been deleted by another process (git in this case) so that attempting to append to the file is no longer effective? On Unix, I'd fstat t

[go-nuts] Re: Sending Context across channel - is it an anti-pattern?

2023-12-06 Thread &#x27;Brian Candler' via golang-nuts
A (cancellable) context is mostly just a channel, which is closed as a broadcast signal, wrapped in an interface. I don't think that how you pass it around makes any difference, including sending it over another channel. Aside: it can be argued that "worker pool" is an anti-pattern in Go. Gorou

[go-nuts] Re: Using Go in picore (tinycore)

2023-12-06 Thread &#x27;Brian Candler' via golang-nuts
You should note that you don't necessarily need to install the go compiler on your target machine. You can build ARM binaries on an x86_64 machine for example - set the parameters GOOS and GOARCH. Go is especially good for this sort of cross-compilation, as it doesn't require any special toolch

[go-nuts] Re: Mongo Go Models (mgm) module and order by

2023-11-22 Thread &#x27;Brian Candler' via golang-nuts
https://github.com/Kamva/mgm/discussions perhaps? (Open, but nothing posted since June 2022). On Wednesday, 22 November 2023 at 17:02:35 UTC Tong Sun wrote: > Any Mongo Go Models (mgm) user here? > https://github.com/Kamva/mgm > > Looks like that mgm can do aggregation but not "order by". > Is

[go-nuts] Re: Deciding between better documentation or making a module harder to misuse

2023-11-18 Thread &#x27;Brian Candler' via golang-nuts
Maybe you're overthinking this. One option would be for Number to have a boolean attribute saying whether it's definitely finite, exposed as an IsFinite() method on Sequence. Calling FindLast() on a sequence where IsFinite() is false would panic. It's not compile-time safe, but it's better than

[go-nuts] Re: Go-native abstract service interface design

2023-11-17 Thread &#x27;Brian Candler' via golang-nuts
I think it depends on what your semantic contract is for this interface. If the caller starts a server with Run(ctx), is it implied that cancelling of ctx should stop the running server? If so, ISTM that there is no need for a separate Shutdown() method. (And there would be no need for App and

[go-nuts] Re: Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-15 Thread &#x27;Brian Candler' via golang-nuts
On Tuesday, 14 November 2023 at 03:38:04 UTC Mike Schinkel wrote: 1. A value variable and multiple value receivers <--- compiles 2. A pointer variable and multiple value receivers <--- compiles 3. A pointer variable and multiple pointer receivers. <--- compiles 4. A value variable and multiple

[go-nuts] Re: Handling EOF when using json.NewDecoder() from named pipe

2023-10-17 Thread &#x27;Brian Candler' via golang-nuts
Are you sure that the writer isn't closing the named pipe between writing JSON objects? If necessary you can check this with strace. I'm pretty sure you'll get an EOF in the *reader* when the *writer* closes from their side. You can demonstrate this with the shell: (In terminal 1) mkfifo /tmp/f

[go-nuts] Re: Is there a race in exec.CombinedOutput?

2023-10-04 Thread &#x27;Brian Candler' via golang-nuts
Code reference: https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=523-565 * c.writerDescriptor creates the pipe, and a copying function is appended to the slice c.goroutine. This slice contains the functions which will be started in their own goroutines. * c.childStdo

[go-nuts] Re: Why doesn't the database/sql package in Go support using placeholders "?" to replace the database name and username in SQL statements?

2023-09-18 Thread Brian Candler
placeholder to the DB server, but the > DB's support of placeholders is limited to only a subset of queries (or > places inside a query) — as the link to SO's answer, shared previously, > explained. > > Hope this makes it a little bit more clear. > > On Sunday,

[go-nuts] Re: cannot find package "github.com/go-redis/redis/v8"

2023-09-18 Thread Brian Candler
You always need a go.mod file if you are importing other modules. But if you're not publishing your code, you can name your own module however you like: "go mod init example" is fine. On Monday, 18 September 2023 at 11:27:09 UTC+1 Aadi Sharma wrote: > I am using go-redis package and can not use

[go-nuts] Re: Help with WASM performance

2023-09-16 Thread Brian Candler
What WASM runtime are you using to execute the code? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discus

  1   2   3   4   5   6   7   8   9   >