Re: [go-nuts] go run, add string value definition with space

2023-11-13 Thread 'Michel Levieux' via golang-nuts
Hi! Not an expert at all, but it seems the format is "package-qualified.identifier=value", with value being able to just contain spaces out of the box, so running: go run -ldflags="-X 'main.MyVar=this is a string'" main.go works for me. Note that for parsing the whole thing correctly, the whole

Re: [go-nuts] In golang spec, if it cast the variable, pointer that cast returns is changed?

2023-10-10 Thread 'Michel Levieux' via golang-nuts
Hi, Note that this has nothing to do with casting. `after` and `before` are not pointers, they're plain old `int` variables (or `DefinedInt` in your example but that does not change anything). When you do `after := whatever`, you're declaring (and assigning) a new variable `after` to hold the

[go-nuts] Re: First stable version of several package under golang.org/x/

2022-10-27 Thread 'Michel Levieux' via golang-nuts
Thank you for the detailed answer! Indeed this may not warrant any announcement, just wanted to be sure I wasn't missing something! :sweat_smile: I'll follow that closely. Thanks! On Thursday, October 27, 2022 at 2:10:15 AM UTC+2 Heschi Kreinick wrote: > Yeah, text and tools were already

[go-nuts] First stable version of several package under golang.org/x/

2022-10-26 Thread 'Michel Levieux' via golang-nuts
Hi all, I was bumping the dependencies of our codebase today, and noticed that many packages under golang.org/x/ had upgraded from a pseudo-version to a real, semver version: - golang.org/x/net v0.

Re: [go-nuts] Generic func to transform []*x to []X if *x implements iface X?

2022-08-26 Thread 'Michel Levieux' via golang-nuts
I guess this defeats what you were trying to accomplish, but does this answer your needs? https://play.golang.com/p/5kPX8F_u24l Cheers, On Fri, Aug 26, 2022 at 9:42 AM Frank Schröder wrote: > Thank you. Are there plans to add a type constraint which would allow > this? Maybe something like

Re: [go-nuts] Generic interface compiles with incorrectly instantiated types

2022-06-21 Thread 'Michel Levieux' via golang-nuts
Hi, I'm not a generics expert either, but I think there is a misunderstanding here: The A in the Wrap[A any] is not the same as the A in Val[A any]. When you instantiate the Extract function with Extract[string], it expects a Wrap[string], which is, in fact, just a type implementing isWrap. The

Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-25 Thread Michel Levieux
Edit: I said "communicate with its caller" but in practice it might as well be another goroutine or the caller of the caller, either way the construct and the logic standing behind it are exactly the same :) Le mar. 25 févr. 2020 à 09:42, Michel Levieux a écrit : > Hi Juan, &

Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-25 Thread Michel Levieux
Hi Juan, You cannot terminate a function execution from its caller if you did not pass it an argument (most likely a channel) which it can use to communicate with its caller, and terminate itself when the timeout is reached. The simplest example I can think of is the following:

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-19 Thread Michel Levieux
Though I think I *do* agree with you on that particular point (zero-value design), I'd say this argument is rarely a real one. Let me explain myself: However clever Google's thousands of programmers are, there might be places for improvement and I personally want people to try and propose

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread Michel Levieux
Hi Kloster08, In addition to what others have already pointed out, I'd like to bring you another case that seems problematic to me concerning the construction of a "usable nil value" for maps, in the sense that a zero-value map could be written and read right away without any initialization.

Re: [go-nuts] Re: Error checking in Go: The `try` keyword

2020-02-07 Thread Michel Levieux
Hi, I'd like to add that for this particular purpose, I find the keyword "try" quite inappropriate. It makes sense in other languages, either with a *catch* "counterpart" or not. But in those cases (at least those I'm aware of), you're not trying a value, which makes no sense to me. You try an

Re: [go-nuts] Re: Attaching a Finalizer to a struct field holding a slice or the slice's underlying array

2019-12-31 Thread Michel Levieux
Hi John, I'm not sure what I'm about to say (i can't test anything right now), but in your last example, wouldn't it be that the finalizer is never called because the function you give it is a closure that holds a reference of b.Payload itself? Thus the GC would consider b.Payload never

Re: [go-nuts] What happens to completely useless effectless conditions at compile-time?

2019-12-23 Thread Michel Levieux
Hi Ian, Yes, sorry I forgot to specify I was using the standard go compiler. Thank you for your answer! Le sam. 21 déc. 2019 à 07:49, Ian Lance Taylor a écrit : > On Fri, Dec 20, 2019 at 5:07 PM Michel Levieux > wrote: > > > > I was working on a project and for simplic

[go-nuts] What happens to completely useless effectless conditions at compile-time?

2019-12-20 Thread Michel Levieux
Hi everyone, I was working on a project and for simplicity reasons I just happened to write a lot of useless, effectless conditions. What I mean by "useless, effectless condition" is a condition that makes no function call, that has no body, and that makes no assignment of any variable outside

Re: [go-nuts] Need advice on AST formatting

2019-10-28 Thread Michel Levieux
Oh, well I'm glad it solved the problem for you Denis! Unfortunately, it seems mine's somewhere else since I was already using token.NewFileSet()... I think I might have to "re-handle" the spacing logic within my AST since I'm changing many many things and it's possible that I just break the

Re: [go-nuts] Need advice on AST formatting

2019-10-22 Thread Michel Levieux
Hi Denis, In a project of my own I encountered the same issue. This program moves a go project to another location, then it remembers imports (that are necessary), exported types, functions and package-scope values (var / const) and maps them in the original go project to the newly created one.

Re: [go-nuts] Re: Package-to-package bindings and package-scope variables

2019-09-18 Thread Michel Levieux
s > https://github.com/KSubedi/gomove > > > Le mardi 17 septembre 2019 10:34:36 UTC+2, Michel Levieux a écrit : > >> Hi again Clément, >> >> It is indeed an uncommon practice, but I can explain my motivations >> behind this little project: >> Where I w

Re: [go-nuts] Re: Package-to-package bindings and package-scope variables

2019-09-17 Thread Michel Levieux
to inject public symbols of C funcs. > e.g. //go:linkname byteIndex strings.IndexByte > > Maybe someone else with a deeper knowledge can help you figure that out. > > I don't have the feeling that i answered your questions, sorry for that. > > Le lundi 16 septembre 2019 15:

Re: [go-nuts] Re: Package-to-package bindings and package-scope variables

2019-09-16 Thread Michel Levieux
u have found out. > > Le lundi 16 septembre 2019 14:27:01 UTC+2, Michel Levieux a écrit : >> >> Hi all, >> >> I'm developing a command that is a utility to move packages around while >> keeping compatibility with softwares that import those packages. Maybe >&

[go-nuts] Package-to-package bindings and package-scope variables

2019-09-16 Thread Michel Levieux
Hi all, I'm developing a command that is a utility to move packages around while keeping compatibility with softwares that import those packages. Maybe there are commands and utilities that already do approximately the same thing, but I'm mainly doing this to learn to use the go/ast package and

Re: [go-nuts] Re: An old problem: lack of priority select cases

2019-08-28 Thread Michel Levieux
One should also be careful regarding the conceptual demands he or she is making. Having a shared resource (that is complex enough that it cannot be atomically accessed or modified) means essentially that "having multiple writers being transparent to the readers", fundamentally, is not possible.

Re: [go-nuts] Regarding strings replace functions issues

2019-08-28 Thread Michel Levieux
t you accidentally used those raw string literals in the producer >> code with the newline escape sequence that is not supported? >> >> >> >> On 28.08.19 12:32, Durga Someswararao G wrote: >> > Hi, >> > >> > Manually I tried but here

Re: [go-nuts] Regarding strings replace functions issues

2019-08-28 Thread Michel Levieux
Hi, Isn't it that from the other side, you escape the string, or call a method that does it before sending it via tcp? That would explain that all the "\n" become "\\n". Le mer. 28 août 2019 à 12:17, Durga Someswararao G < durgasomeswararao...@gmail.com> a écrit : > Hi Tamás, > > But even in

Re: [go-nuts] Golang project ideas

2019-08-19 Thread Michel Levieux
Hi, Don't know if you're looking for something that has never been done or if you don't really care and just want practice, but those are three ideas I can think of. :) - A web tracker that can be plugged into any website easily - A lightweight real-time bidder - Making an interpreter for a

Re: [go-nuts] Re: Question re fcns that return multiple values

2019-08-07 Thread Michel Levieux
It avoids confusion AND silent errors. Imagine you have: func f() (int, int) func g() (int, int) func h(int, int, int, int) int And somewhere in your code this line appears: v = h(f(), g()) But for some reason, someday you need to change your code and now your function f and g have the

Re: [go-nuts] Does reducing capacity of a slice return memory?

2019-07-19 Thread Michel Levieux
Hello everyone, I might be saying something stupid but I found this topic really interesting and I was wondering: Instead of trying to get the notion of "slice" to replace that of "pointer" in the compiler/runtime reference frame, wouldn't it be possible / less complex to keep track of the

Re: [go-nuts] Re: Concerning the level required to contribute to Go

2019-06-24 Thread Michel Levieux
Hi everyone, Thank you all for all your precious pieces of advice. I think I'm slowly going to have a look at the different possibilities to contribute to the Go language. As some of you noticed, I'm kind of more motivated when I think about helping in the go codebase than other sorts of tasks

Re: [go-nuts] Creating a request language from scratch

2019-06-07 Thread Michel Levieux
Thx, I'm gonna have a look at this :) Le ven. 7 juin 2019 à 10:12, Rob Pike a écrit : > Some minor advice: > > > https://commandcenter.blogspot.com/2011/08/regular-expressions-in-lexing-and.html > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts"

[go-nuts] Creating a request language from scratch

2019-06-07 Thread Michel Levieux
Hi guys! I'm trying to develop an interpreter for a proprietrary language, which I named klang for the moment (for kdata language - kdata being an abreviation of CapitalData, the company I'm working for). This language is pretty simple, the goal being to simplify as much as possible requesting

Re: [go-nuts] [48]byte should be make to empty

2019-06-06 Thread Michel Levieux
Hi, It is not quite clear what you are trying to do, but if I understand it well: var array = [48]byte{} should initialize your array with zero values. Le jeu. 6 juin 2019 à 15:48, sasikala tholisam a écrit : > test [48]byte make to empty.. > How to do it? > > -- > You received this message

Re: [go-nuts] Re: How to run a go method on multiple cores ?

2019-05-07 Thread Michel Levieux
https://golang.org/ref/spec#Go_statements Small but clear IMO. That said, for the everyday-use of goroutines, there's not much to know about them. If you really want / need to go deep into the way goroutines work, there are articles written by people on the web (

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-07 Thread Michel Levieux
If the only thing you want to achieve is: main: run engineA run engineB engineA: do something if engineB is down -> run engineB engineB: do something if engineA is down -> run engineA You don't really need the two processes to run on different cores, nor do you need them to be constantly

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-07 Thread Michel Levieux
.Thankyou..:) > > Can we also find the processor on which this go routine is running? > > Thanks > > > On Mon, 6 May 2019, 17:43 Michel Levieux, > wrote: > >> Hello, >> >> Is: >> >> type Y struct { >> >> M string >> N string &

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-06 Thread Michel Levieux
Hello, Is: type Y struct { M string N string } func initalize() Y{ // I have a func that return an object ob type Y. } var obj1 Y go func() { obj1 = initalize() }() var obj2 Y go func() { obj2 = initalize() }() What you are looking for? Le lun. 6 mai 2019 à 13:59, Jan Mercl

Re: [go-nuts] Re: Discrepancy between htop and memstats

2019-05-02 Thread Michel Levieux
uld show you what objects > leak memory. > > [1]: https://blog.golang.org/profiling-go-programs > > On Tuesday, April 30, 2019 at 3:36:34 PM UTC+2, Michel Levieux wrote: >> >> Hi all, >> >> I'm currently having a lot of trouble debugging the memory usage of th

[go-nuts] Discrepancy between htop and memstats

2019-04-30 Thread Michel Levieux
Hi all, I'm currently having a lot of trouble debugging the memory usage of the program I'm working on. This program, everyday at a given time, reloads a bunch of data (that's been updated by another program) into its memory. The following function: // PrintMemUsage outputs the current, total

Re: [go-nuts] source for scheduler and gc?

2019-04-03 Thread Michel Levieux
I don't know what you're trying to achieve but I think: a. that it's not possible to have a program keep a consistent state while enabling such behaviour b. that there's a better way to do what you want to do Maybe explaining (even vaguely) what your purpose is could help? Le mer. 3 avr. 2019 à

Re: [go-nuts] Re: Confusing Behavior When Compiling an Assignment Using a Map

2019-03-29 Thread Michel Levieux
Think of something like this https://play.golang.org/p/GyPlYefS7ZW (maybe the example could be simpler) --> ok means we found the most nested value or the least one? Le ven. 29 mars 2019 à 16:55, a écrit : > Yes, that is expected. The right hand side of the assignment is > `b[1].code`. That is

Re: [go-nuts] Channel Feature Suggestion

2019-02-21 Thread Michel Levieux
No but you can for example have a second channel from the pusher to the observer that signals (in case it cannot push anymore) the latter that the channel to which it tries to push to is full. The opposite is true from the consumer, that could signal via a second channel, when it cannot pull from

[go-nuts] Handling connection retries on a highly-available service

2019-02-11 Thread Michel Levieux
Hi guys. I need a little help here. I work in a digital marketing company, where we have a program that receives a lot of requests every second (counted in thousands) and logs its behaviour via a logger that runs on another server. We are currently trying to implement a connection-retry system

Re: [go-nuts] Re: Strange behaviour of left shift

2018-12-06 Thread Michel Levieux
the hardware level, most platforms are implementing bitshifts > with multiplication. But sometimes not, also. The reason to use >> and << > should be to use, if available, the hardware's shift operator, as it > otherwise falls back to multiplication. > > On Wednesday,

Re: [go-nuts] Strange behaviour of left shift

2018-12-05 Thread Michel Levieux
> too large for an int; it needs a uint64 to hold it. > > Andy > > On Dec 5, 2018, at 8:35 AM, Michel Levieux > wrote: > > Hi guys, > > With a colleague of mine, we've run into a strange issue today. When we > look at package math, in const.go, we can se

[go-nuts] Strange behaviour of left shift

2018-12-05 Thread Michel Levieux
Hi guys, With a colleague of mine, we've run into a strange issue today. When we look at package math, in const.go, we can see this line : MaxUint64 = 1<<64 - 1 > > which I assume works pretty well. But if I do the same in a test main and try to 'go run' it, with this line : const v = 1 << 64 -

Re: [go-nuts] Rethink possibility to make circular imports

2018-12-03 Thread Michel Levieux
Hi everyone. I think for the moment I will agree that it would bring more pain to allow circular imports in Go than it would solve problems. One of the most convincing arguments I have read here so far is that it would probably cause many design flaws all around and make many packages very hard to

Re: [go-nuts] Rethink possibility to make circular imports

2018-11-30 Thread Michel Levieux
e. Le jeu. 29 nov. 2018 à 23:30, Rob Pike a écrit : > And to reduce build time, especially for incremental builds. > > -rob > > > On Fri, Nov 30, 2018 at 8:17 AM Ian Lance Taylor wrote: > >> On Thu, Nov 29, 2018 at 5:22 AM Michel Levieux >> wrote: >> >

[go-nuts] Rethink possibility to make circular imports

2018-11-29 Thread Michel Levieux
The last few days I've been thinking a lot about the fact that Go does not allow circular imports. I'm not really sure of why it currently works that way, but from what I've understood the way the compiler works - which is also the reason why compilation of Go programs is much faster than other

Re: [go-nuts] Re: is it possible to speed up type assertion?

2018-11-25 Thread Michel Levieux
> > No offense intended, but that code is wrong on so many levels... I strongly believe you that you are not trying to offend anyone, but this question is interesting for me too, and I'd like more details. Could you please explain, from worst to "less worst", what's wrong with this code?

Re: [go-nuts] recommend that error and panic auto coverting

2018-11-22 Thread Michel Levieux
heck/handle. > > YMMV, of course. > > (there's also the secondary issue that panic takes an interface{}, not an > error, so it's not entirely clear what it would mean to convert a panic > into an error - but that's relatively minor) > > On Thu, Nov 22, 2018 at 12:08 PM Michel Levieux

Re: [go-nuts] recommend that error and panic auto coverting

2018-11-22 Thread Michel Levieux
nov. 2018 à 11:36, Axel Wagner a écrit : > This seems very similar (almost identical, safe for the choice of words > maybe) to the Go 2 error handling draft design > <https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md> > . > > On Th

Re: [go-nuts] recommend that error and panic auto coverting

2018-11-22 Thread Michel Levieux
I do like the idea, but the form looks strange IMO. I'd rather make the "Must" convention a new keyword for the first example, and another one for the second (though I don't see a clear keyword for that). For a panic on error you'd write : data := must error_func() Maybe the "try" keyword would

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Michel Levieux
GetPrev() *X > } > } > > what you are suggesting is similar to having an interface with two > nameless functions returning *X. > > > > > Le mar. 20 nov. 2018 à 15:52, Burak Serdar a écrit : > >> > >> On Tue, Nov 20, 2018 at 7:36 AM Michel

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Michel Levieux
f type X"). The implementation you chose to adopt for this function does not matter (?). Le mar. 20 nov. 2018 à 15:52, Burak Serdar a écrit : > On Tue, Nov 20, 2018 at 7:36 AM Michel Levieux > wrote: > > > > Yes, but you can just specify the concract like : > > > >

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Michel Levieux
two ints in its arguments (along with a string), but you do not name the parameter. I think one might not forget that we're talking "type signature" here, and not type definition :) Le mar. 20 nov. 2018 à 15:26, Burak Serdar a écrit : > On Tue, Nov 20, 2018 at 6:27 AM Michel

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Michel Levieux
I guess X is the type that is represented by the struct, the meaning being : "the type X is a struct that contains a field that is a pointer to a value of the same type". EDIT : I think the "next" word, which is here the name of the field, can even be omitted. The relevant information here is to