https://pkg.go.dev/github.com/pierrre/assert#section-readme
Le vendredi 23 février 2024 à 09:34:43 UTC+1, Harmen a écrit :
> On Thu, Feb 22, 2024 at 04:41:53PM -0800, Seth Hoenig wrote:
> > https://github.com/shoenig/test
> >
> > We've been using this for a couple years now, and it's been great.
Currently we can register a cleanup function on a single test. This
function is executed when the test finishes.
But there is no way to execute a cleanup function after all the tests of a
package are executed.
Use case: let's say I want to build a "test helper" library that is used by
other pro
à 14:43:51 UTC+1, axel.wa...@googlemail.com a
écrit :
> On Thu, Dec 22, 2022 at 2:24 PM Pierre Durand wrote:
>
>> Same question for `len()`: is there a way to declare a constraint that
>> matches types that support `len()` ?
>
>
> For this, the workaround you posted
Same question for `len()`: is there a way to declare a constraint that
matches types that support `len()` ?
Le jeudi 22 décembre 2022 à 14:23:22 UTC+1, Pierre Durand a écrit :
> Is there a way to declare a "nillable" constraint that matches all types
> that can be nil (pointer,
Is there a way to declare a "nillable" constraint that matches all types
that can be nil (pointer, slice, map, etc.) ?
I would like to write a function, that receives a parameter (with a generic
type), and check if this parameter is nil.
I found a very ugly way to write it: https://go.dev/play/p
See "halt_on_error"
https://golang.org/doc/articles/race_detector.html#Options
Le mardi 8 septembre 2020 à 14:47:11 UTC+2, chole...@gmail.com a écrit :
> Code with data races is invalid code, we shouldn't let it run once we find
> a data race. Actually, since Go 1.5, when runtime finds concurren
The stack trace is identical to https://github.com/golang/go/issues/3
Le jeudi 2 avril 2020 23:23:02 UTC+2, Robert Engels a écrit :
>
> Does your code use any unsafe or cgo?
>
> On Apr 2, 2020, at 11:38 AM, 'hamid...@live.com ' via
> golang-nuts > wrote:
>
>
> Hi folks,
>
> An issue with th
Well, in my case I don't want to convert the []byte to hexadecimal string,
because it uses 2x more memory.
The code contains a huge map where the key is an MD5 hash.
Please note that I'm not personally working on this.
I was reviewing the code written by a coworker, and I noticed that there
was
OK, thank you !
Le mardi 20 août 2019 10:34:55 UTC+2, djeg...@gmail.com a écrit :
>
> On Tue, Aug 20, 2019 at 10:12 AM Pierre Durand wrote:
> >
> > I know that by convention Go string contain UTF-8 encoded text.
>
> To my understanding this is not entirely true -- see
&
I know that by convention Go string contain UTF-8 encoded text.
Is it recommended/a good practice to store invalid bytes in a string ?
The use case:
- compute a hash => get a []byte
- convert the []byte to string (this string is not UTF-8 valid)
- use the string as a map key
In my case, the hash
Hello !
I'm trying to write a tool that will:
- parse my code, and find variable assignment
- check if the assigned variable is a parameter in the current function (or
a function parameter in the current scope)
func myFunc(a *A){
a.foo = "bar"
}
In the code above, I want to detect that "a"
ok, thank you !
Le lundi 1 octobre 2018 19:31:58 UTC+2, Ian Lance Taylor a écrit :
>
> On Mon, Oct 1, 2018 at 7:56 AM, Pierre Durand > wrote:
> >
> > My code:
> > package main
> >
> > func main() {
> > a := 1
> > _ = func() {
> >
My code:
package main
func main() {
a := 1
_ = func() {
a := 2
_ = a
}
_ = func() (a int) {
a = 2
return a
}
_ = a
}
"go vet -shadow" reports a problem with the first function/closure, but
nothing for the second one.
Why ?
If I understand correctly, it doesn't consider variable declaration in a
OK ! thanks.
Le lundi 10 septembre 2018 16:39:28 UTC+2, Sam Whited a écrit :
>
>
>
> On Mon, Sep 10, 2018, at 09:27, Pierre Durand wrote:
> > When I learned Go a few years ago, I was told to always defer/close the
> > HTTP request body, otherwise it will cause a reso
When I learned Go a few years ago, I was told to always defer/close the
HTTP request body, otherwise it will cause a resource leak.
But today I read this: https://golang.org/pkg/net/http/#Request.Body
// The Server will close the request body. The ServeHTTP
// Handler does not nee
Thank you! :)
Le mardi 5 décembre 2017 08:10:50 UTC+1, Alec Thomas a écrit :
>
> Hello,
>
> Through the efforts of many contributors, and in particular those of
> Daniel Nephin, v2.0.0 has been released. You can grab it here:
>
> https://github.com/alecthomas/gometalinter/releases/tag/v2.0.0
Did you test Go 1.9 betas or RCs ?
Le lundi 28 août 2017 01:14:20 UTC+2, oldCoderException a écrit :
>
> Hi all,
>
> I upgraded to Go 1.9 and since then UDP multicast code that has been
> running fine for over a year is now failing on JoinGroup. I run this
> program on linux Mint 18 as root (us
Goroutine execution is not deterministic.
--
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.
For more options, visit https:
I use these functions in init():
https://golang.org/pkg/html/template/#Must
https://golang.org/pkg/regexp/#MustCompile
Le mercredi 31 mai 2017 21:24:58 UTC+2, Peter Kleiweg a écrit :
>
> If a package can't be used because some precondition can't be fulfilled,
> you can use a panic. Then the whole
>
> I "believe" in PHP a for loop keeps the variable in memory until the end
> of the script and if you want to remove the variable from memory you need
> to unset the variable to help conserve memory.
https://en.wikipedia.org/wiki/Cargo_cult
Le mardi 9 mai 2017 00:29:14 UTC+2, var...@gmail.
case errCh <- err:
> default:
> select {
> case <-ctx.Done():
> }
> }
>
> Again, take this with a grain of salt. I didn't check the spec or code,
> just off the top of my head.
>
>
> Best,
>
> On Thursday, April 6, 2017 at 11:29:58 AM UTC+3, Pierr
t;
>
> On Wednesday, April 5, 2017 at 4:02:16 AM UTC+10, Pierre Durand wrote:
>>
>> Hello
>>
>> I wrote a small helper to stop an HTTP Server when a Context is canceled.
>> https://play.golang.org/p/Gl8APynVdh
>>
>> What do you think ?
>> Is it OK
Hello
I wrote a small helper to stop an HTTP Server when a Context is canceled.
https://play.golang.org/p/Gl8APynVdh
What do you think ?
Is it OK to use context cancellation for stopping long running functions ?
--
You received this message because you are subscribed to the Google Groups
"gola
This option ? https://github.com/jteeuwen/go-bindata#lower-memory-footprint
Le dimanche 8 janvier 2017 21:46:15 UTC+1, Dave Cheney a écrit :
>
> This is a somewhat known issue. Each token in a parsered .go file is
> represented by a Node structure inside the program. The Node structure is
> larg
https://golang.org/ref/spec#Comments
Le samedi 12 novembre 2016 19:20:10 UTC+1, John Souvestre a écrit :
>
> Ø Also, prefixing all of the need-to-be-commented-out lines with // is
> always safe: https://play.golang.org/p/8Cot8lssO3
>
>
>
> Except for perhaps: https://play.golang.org/p/9xiWFI-S
https://mandelbrot.pierredurand.fr
--
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.
For more options, visit https://group
16 12:49:24 UTC+2, Daniel K a écrit :
>
> Looks good, but you could take advantage of the io writer interface.
> I made a quick example, not sure if it runs (did not test)
>
> https://play.golang.org/p/cYcz2ktoiG
>
> Den onsdag den 6. juli 2016 kl. 11.44.33 UTC+2 skrev Pierre
Ooops, fixed my code: https://play.golang.org/p/vdwDT9WMVr
Le mercredi 6 juillet 2016 11:44:33 UTC+2, Pierre Durand a écrit :
>
> My solution: https://play.golang.org/p/f5H0svLFE0
> What do you think ?
>
> Le mardi 5 juillet 2016 15:30:38 UTC+2, Jan Mercl a écrit :
>>
>>
My solution: https://play.golang.org/p/f5H0svLFE0
What do you think ?
Le mardi 5 juillet 2016 15:30:38 UTC+2, Jan Mercl a écrit :
>
>
> On Tue, Jul 5, 2016 at 11:38 AM Pierre Durand > wrote:
>
> > It works as expected, but in my real code, I'd prefer to avoid mutex.
ere a problem in the *writeBuffer()* function ?
It is very simple, and it looks that it works.
Le mardi 5 juillet 2016 13:46:38 UTC+2, Alex Bligh a écrit :
>
>
> > On 5 Jul 2016, at 10:38, Pierre Durand > wrote:
> >
> > So, I've written writeMutex(), that uses a mutex.
Hello!
My code: https://play.golang.org/p/pg-p17UuEW
I'm trying to append lines to a file concurrently.
My first write() function is buggy, because WriteString() are called by
several goroutines in unexpected order.
So, I've written writeMutex(), that uses a mutex.
It works as expected, but in
31 matches
Mail list logo