Re: [go-nuts] Is there a way to specify or use the tmp directory used in testing?

2022-02-23 Thread Levieux Michel
Use absolute paths? Feels like you're trying to bend something very hard here On Wed, Feb 23, 2022 at 2:54 PM Leam Hall wrote: > My program uses data and template files located relative to the binary. > Since go test creates the binary under test in /tmp/go-build., there > are no data or tem

Re: [go-nuts] Re: Gradual change of package path

2021-12-21 Thread Levieux Michel
Hi Sean! Thank you very much for your answer! After trying out some other options [and calming down], I realized I could indeed just remove the go.mod completely and still have the wiring be functional. For exposed constants (fortunately we didn't have exposed global variables), I just reported th

[go-nuts] Gradual change of package path

2021-12-20 Thread Levieux Michel
Hi all, I have a use-case which I'm not sure I'll be able to tackle using current tooling but just to be sure, I'm asking here. I have a package which originally looked like: / /go.mod /package_name /other_packages... there are no go files at the root of the module, and the code that is "meant"

Re: [go-nuts] Goroutines and mutex

2021-11-28 Thread Levieux Michel
The problem here is you are sending a copy of counter to the anonymous function. You need to either not pass it and use the outer-scope counter directly in the function, or pass a reference to the counter to the function. Hope this helps. Le dim. 28 nov. 2021 à 16:19, Денис Мухортов a écrit : >

Re: [go-nuts] Why IF might not work

2021-11-23 Thread Levieux Michel
I'm not going to point you directly at the solution as this is more of an issue with the way you're trying to solve this. But it's not because the result of your division is comprised between 1.0 and 2.0 that a number is a multiple of the other, especially with floating point numbers. You might wa

Re: [go-nuts] Delete from map failed golang

2021-11-19 Thread Levieux Michel
Hi, I reported your code into the playground for testing, and it seems to be working fine for me: https://play.golang.com/p/udsRN-iUQM8 I designed a simple AuthCtx struct based on your example but that should not change anything. Maybe it would be easier to help with more details. Why do you say

Re: [go-nuts] Re: Is this "functional" approach the right way to Go?

2021-10-20 Thread Levieux Michel
n Go 1.18 this works: > > type DogBuilder[T dogishType] struct { >dog T > } > > func (dog DogBuilder[T]) WithBone(bone Bone) T { > ... > } > > However, Go 1.18 is not released, and furthermore dogishType would still > need setXX() for each T since struct members cannot be put a

Re: [go-nuts] Re: Is this "functional" approach the right way to Go?

2021-10-19 Thread Levieux Michel
Thanks Brian for your answer. Indeed it is hard to convey the whole problem with just a metaphor... But your suggestion that maybe mocking the "contained" parts would work is helpful here. So if the Dog does not itself interact directly with critical systems (DB, git...) then we could provide a Dog

[go-nuts] Is this "functional" approach the right way to Go?

2021-10-19 Thread Levieux Michel
Hi all, I'm facing a particular issue in my company at the moment and can't seem to figure out how to fix it. Hope you can help. For the sake of IP, all code presented here will be crafted. We have part of our code that performs operations with certain properties attached to a specific operation

Re: [go-nuts] write func with optional bool return value

2021-08-27 Thread Levieux Michel
Hi, Optional returns and parameters don't exist in go, what you are referring to is built-in behavior specific to some features. A good way to approach what you want is by assigning it to the anonymous '_' var when you don't want the returned bool. Hope this helps Le ven. 27 août 2021 à 16:58,

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-30 Thread Levieux Michel
Also, though I think it's easy to slip into tests that test the mocks if you don't pay attention, you can have arbitrarily numerous mocks without having bad tests. Unit tests are not designed to reflect your runtime environment at all, they're here to make sure your function (program unit) does wha

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Levieux Michel
I'm not quite sure the intent is the same? Generating models only reduces the cognitive and time overhead of going back and forth from the code to the db. It does not test anything. Having a model that you are sure is a reflection of the db does not help you know that the logic going with it works?

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Levieux Michel
Hi, IMO, specific mocks like DATA-DOG's tend to be complicated to use and have behaviors that should not appear in a mock, which would ideally tend to have no logic at all. There are several mock packages that you can find here [and BTW if you have t

Re: [go-nuts] Re: Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Levieux Michel
Thx all for the response! Giving myself a (tremendous) facepalm, it was _indeed_ the use of litter that destroyed my machine memory. Everything's working fine now. Sorry for the unnecessary noise guys. *retreating in shame* Have a great day! Le mer. 21 juil. 2021 à 16:40, Brian Candler a écrit

[go-nuts] Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Levieux Michel
Hi all, I'm having a very hard time with golang.org/x/tools/go/packages. Spent most of my evening yesterday trying to understand what's happening here. Here's my code: https://play.golang.com/p/5L1N0lSaetB With this very simple code I would expect that the program prints detailed information abou

Re: [go-nuts] Re: How to implement this in golang?

2021-07-08 Thread Levieux Michel
This error is pretty straightforward 😅 You declared a variable (i.e. kk) that is not used after its declaration. Note that assignment is not use. I have to admit I don't know what this variable is supposed to be used for but that does not matter, if you don't know, maybe just try dropping it and se

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread Levieux Michel
You cannot *per se* convert an interface or a struct to a builtin like []byte You might wanna have a look at the Bytes method of *bytes.Buffer, which returns the internal buffer of the type as a slice of bytes. Normally that would have been a good exerci

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread Levieux Michel
[Sorry forgot to hit "Reply all"] Are you trying to cast cmd.Stdout here? What you can do is: buf := new(bytes.Buffer) cmd.Stdout = buf // buf is an io.Writer so this is fine but I don't get the point of the data := foo? Maybe, before trying to convert a whole complex program in Python to a whol

Re: [go-nuts] Named types vs not named types

2021-06-27 Thread Levieux Michel
Hi, I'm not sure what type you are referring to here. This file defines many named types and interfaces and I'd say from a quick read that all of them are used. Could you clarify what you mean? Le dim. 27 juin 2021 à 15:53, Victor Giordano a écrit : > Hello gophers! > > While studing at this s

[go-nuts] go/importer can't find github import referring to internal/ of current module

2021-06-14 Thread Levieux Michel
Hi guys, Didn't really know what to put in the title, I have a file hierarchy like the following: - gest (root of module) -- cmd --- gesterate command files (see below) -- internal --- callstack internal library files (see below) -- library files (see below) in the cmd/gesterate/ folder

Re: [go-nuts] Why do type aliases change behaviour (i.e. json.Unmarshal)?

2021-03-15 Thread Levieux Michel
This is because per the Go spec: https://golang.org/ref/spec#Type_declarations You're not creating an alias to Token, but defining a new type from it. If what you are looking for is an alias (meaning to have the "WrappedToken" identifier refer to the exact same type as Token), you need to do: type

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Levieux Michel
Your need is not only to sort your data elements then..? Using the previously advised solution you can just range the slice *after* you sort it, so you can just check for the next element, which I'd say is not *too bad*, what are your performance constraints? Le sam. 13 mars 2021 à 21:33, Vasiliy

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Levieux Michel
Hi, You should take a look at the sort package from the stdlib, it contains an interface that you can easily implement for such problematics :) Hope this helps! Le sam. 13 mars 2021 à 14:37, Vasiliy Tolstov a écrit : > Hi! > I'm stuck at sorting stuff like > > []string{"xxxkey","xxxval","zzzke

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Levieux Michel
It's not because the arguments didn't appear numerous / convincing enough that they were not taken into account. You are just stating your incapacity to accept that you might be wrong, as anyone can, and that you cannot discuss something (clearly because you don't want to *discuss*, you want people

Re: [go-nuts] how can I solve it 2 decimal places float32 with fmt.Println()

2021-03-04 Thread Levieux Michel
If the problem is that you want to have a newline at the end of your answer you can just put "\n" at the end of your string. If you want to do the same using fmt.Println, you can check fmt.Sprintf :) Otherwise indeed your issue is not that clear to me. Le jeu. 4 mars 2021 à 17:31, Tareq Ibna a é

Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread Levieux Michel
I think the question was: "given your proposal here, I can write func (string | []byte in1, string | []byte in2) which enforces that in1 and in2 must be either of type string or type []byte, but how do I tell the compiler that in1 and in2 must be of the *same type* (whether it is string or []byte)

Re: [go-nuts] [generics] moving the last type parameter to a type outside the square brackets

2021-01-05 Thread Levieux Michel
There is a delimiter in 'chan int' -> ' ' (space) I don't think it is a good assumption that "most generic types would only have 1 type-parameter" (or 2, or 3, or any other arbitrary number for what it's worth). Moreover, I don't think it is a good idea to assimilate builtin language constructs to

Re: [go-nuts] An important proposal will fail without your support

2020-03-11 Thread Levieux Michel
Hi Jon, It seems you missed something here. "Please like my proposal or everyone loses" is not an argument. We don't work that way here. You have suggested the language needs a feature, and have gotten many answers from people that think it does not. Keeping on repeating the same argument forever

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 Levieux Michel
@Sam, hi, yes, that was the point ^^ My example was here to say "ok, so let's say the first case works because we have made uninitialized maps work, but how do we handle the second case?" It was not made to be runnable as is, I just wanted it to be readable :) Sorry if that was not clear Le lun.

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

2019-06-21 Thread Levieux Michel
ng to build a working compiler which supports a new keyword. > > Also, recognize the four years of experience isn't all that much, and > listen to feedback. You start to form a good mental image of how > programming languages solve problems once you've done enough work in eno

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

2019-06-21 Thread Levieux Michel
Hi all, I've been thinking a lot about that lately and can't seem to find an answer on my own. I would be soo glad and fulfilled if I could contribute to the go project. However, I am wondering about whether or not it is my lack of knowledge of the go language that prevents me from taking the