[go-nuts] Constrain a type parameter to be assignable to another

2022-03-16 Thread Michael Andersen
Hi Is there a way to constrain one parameter to be assignable to another? For example, in ye olde days, I'd have: type Iface interface { // ... } type Concrete1 struct { /* ... */ } var _ Iface = {} type Concrete2 struct{ /* ... */ } var _ Iface = {} // Repeat ad nauseam Now, I'm finding

Re: [go-nuts] Runtime panic

2022-03-16 Thread Stavros Filargyropoulos
Thanks Ian! Removing UPX solved the problem. On Tue, Mar 15, 2022 at 9:25 PM Ian Lance Taylor wrote: > > On Tue, Mar 15, 2022 at 9:09 PM Stavros Filargyropoulos > wrote: > > > > On an embedded 16 core arm device we have been observing infrequent runtime > > crashes, with different signatures

Re: [go-nuts] Re: Parsing a time as a prefix of a larger string

2022-03-16 Thread Rob Pike
I would approach the problem a different way and ask the question, how do I split the string to separate the time? The time parser doesn't have to be the one to do this. For instance, uou could require a marker (if the word INFO or its substitute isn't already one), such as a spaced hyphen:

[go-nuts] Goroutines - handles, signals, and signal handlers

2022-03-16 Thread 'Mumbling Drunkard' via golang-nuts
I'm currently working on a project where I emulate a RISC-V processor for the purpose of using Go when teaching concepts of operating systems. I'd like for the emulator to resemble a "real" processor to the point that a realistic operating system can be implemented with most of the interesting

[go-nuts] Re: Parsing a time as a prefix of a larger string

2022-03-16 Thread ben...@gmail.com
> How does the user control the format of the timestamp? How do you get the > time.Parse layout? > The project is a lightweight service manager, so the user "controls" the format of the timestamp based on the service they're running. For example, if they're running nginx, it will output logs

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread 'Axel Wagner' via golang-nuts
Also, I kind of assume that you have little control over the types (given that you say it's infeasible to touch all places where it's created) but the simplest solution might, of course, be to make the zero value of Node implement Lockable correctly: type Node struct { BasicNode // Note: By

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread 'Axel Wagner' via golang-nuts
Let me make one more concrete suggestion: On Thu, Mar 17, 2022 at 12:18 AM Alex Besogonov wrote: > The real example would look like this: https://go.dev/play/p/mwUfh4_RBUU > - you do see why it's a tad problematic? > Here is how you could write that, assuming `GetNode` returns a `*Node`:

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread 'Axel Wagner' via golang-nuts
FWIW I understand that I come off as unsympathetic, insisting that you should fix the incorrect code, even though it is hard. But I am *very* sympathetic. I know perfectly well what it means to inherit a messy code base full of bugs and be overwhelmed by the amount of effort needed to fix it. But

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread 'Axel Wagner' via golang-nuts
On Thu, Mar 17, 2022 at 12:18 AM Alex Besogonov wrote: > No. It should be a POINTER to a struct, which would have been fine. > Instead Go's reflection incorrectly latches on the type of the embedding > structure. > Your code says: var n3 Node LockObjects(n2, n3, n1) You are thus storing a

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread Patrick Smith
On Wed, Mar 16, 2022 at 3:25 PM Alex Besogonov wrote: > Note that in your case, the dynamic value of that interface *is not nil*. > It's a struct value. Structs can not be nil. > > Incorrect. Go language allows coercing a struct with an embedded pointer > to an interface. Spec: > "If S contains

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread Alex Besogonov
> The reflect code panics, because you are comparing a struct value to nil. >> Struct values can not be nil. >> >> No. I’m comparing AN INTERFACE, not a struct. >> > You are using `reflect` to inspect the dynamic value of that interface. > That dynamic value is a struct. > No. It should be a

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread Alex Besogonov
> Here's a simplified version of the real code: > https://go.dev/play/p/8LfgIGhd8GR - it > compiles without any issues. > > Yes it compiles. Plenty of buggy Go code will compile. Here is another > example of buggy

Re: [go-nuts] Golang Packages

2022-03-16 Thread 'Sean Liao' via golang-nuts
It's available if you use the generated pseudoversion as the version in the pkgsite url . you can get it via a call to go get (which is necessary to populate the proxy for pkgsite). A bit difficult to demonstrate on your module as testbranch right now points to v0.0.1 which takes precedence. On

Re: [go-nuts] debug.ReadBuildInfo is info.Main.Version always "(devel)"

2022-03-16 Thread 'Sean Liao' via golang-nuts
not yet https://github.com/golang/go/issues/50603 -- 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

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread Alex Besogonov
On Wednesday, March 16, 2022 at 12:29:07 PM UTC-7 axel.wa...@googlemail.com wrote: > On Wed, Mar 16, 2022 at 7:02 PM Alex Besogonov > wrote: > >> Nope. Your solution doesn't work either: >> https://go.dev/play/p/DSik2kJ-gg4 (it doesn't crash, just falsely >> returns 'false'). >> > That's

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread 'Axel Wagner' via golang-nuts
On Wed, Mar 16, 2022 at 7:02 PM Alex Besogonov wrote: > Nope. Your solution doesn't work either: https://go.dev/play/p/DSik2kJ-gg4 > (it doesn't crash, just falsely returns 'false'). > That's your original code. I assume, though, you are trying to demonstrate that this doesn't return `true`

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread Alex Besogonov
Nope. Your solution doesn't work either: https://go.dev/play/p/DSik2kJ-gg4 (it doesn't crash, just falsely returns 'false'). What I'm trying to check is pretty straightforward: do I get the nil value passed to a function. All types are completely valid, the structure is correctly cast to the

Re: [go-nuts] IsNil check. How?

2022-03-16 Thread 'Axel Wagner' via golang-nuts
On Wed, Mar 16, 2022 at 6:21 PM Alex Besogonov wrote: > I'm trying to solve the eternal "interface == nil" problem and I can't > find a solution in this case: https://go.dev/play/p/DSik2kJ-gg4 > ISTM that you are discovering why this check just is not an interesting check to make in the first

[go-nuts] IsNil check. How?

2022-03-16 Thread Alex Besogonov
Hi! I'm trying to solve the eternal "interface == nil" problem and I can't find a solution in this case: https://go.dev/play/p/DSik2kJ-gg4 It looks like casting to the base pointer type confuses the reflection package. Is there a way to solve this? PS: PLEASE do add "nilptr" to the language

[go-nuts] Re: Parsing a time as a prefix of a larger string

2022-03-16 Thread peterGo
On Tuesday, March 15, 2022 at 11:35:06 PM UTC-4 Ben wrote: > We're making a log processing program that needs to parse times from the > prefix of a larger string, in this case in a log line such as: > > 2006-01-02 15:04:05 INFO this is a log message > > We need to parse the "2006-01-02 15:04:05"

[go-nuts] Golang Packages

2022-03-16 Thread Nickolas Daniel Filip
Hi! So what I'm trying to achieve is the following: I have a github repository containing my golang source code: github.com/nickolasdaniel/golang-ginrest On this repo I have 2 branches: 'main' and 'testbranch' I can access my source code on the pkg.go.dev as following:

[go-nuts] Is the disconnection synchronization solid in gorilla/websocket?

2022-03-16 Thread Zhaoxun Yan
Since read and send messages are in different functions/goroutines, when an error occurs, how can they be synchronized? Suppose I set up a listen goroutine by this function below, with `conn` as a global variable of the connection: func listen(){ for{ _, message, err :=

[go-nuts] Re: Spam email

2022-03-16 Thread Anderson Queiroz
It could also be your SMTP server, are you able to send the same email, and not having it marked as span, through another client? On Wednesday, 16 March 2022 at 00:12:43 UTC+1 Rick wrote: > An email is designated as Spam by a heuristic. The heuristic takes into > account the name of the server

[go-nuts] no git tags in go 1.18 new buildinfo

2022-03-16 Thread JeffG
hi, I just tested the new 1.18 BuildInfo addition (see https://go.dev/doc/go1.18#debug/buildinfo ) and was hoping to get ride if our build wrapper(makefile) and the ldflags trick to embed the git tag in the main binary. But it seems this new feature doesn't know about git tags ? Have I

Re: [go-nuts] Re: New edition of the Go Programming Language comming soon ?

2022-03-16 Thread roger peppe
On Tue, 15 Mar 2022 at 04:58, Rob Muhlestein wrote: > The essential issue is that there are a number of resources for people > "with prior programming experience" and literally none for people learning > Go as a first language. > It does have significant omissions (all programs in the book can

[go-nuts] debug.ReadBuildInfo is info.Main.Version always "(devel)"

2022-03-16 Thread Amnon
I was hoping to use debug.ReadBuildInfo to avoid using ugly --ldflags -X directives to insert the current git version into my runtime. This works as expected for dependencies. But the main module comes out as (devel). Is there a way to use ReadBuildInfo to get the actual tag and has of the main