Re: [go-nuts] Hard-to-explain race detector report

2023-06-07 Thread Caleb Spare
t; You might claim, that for infrastructural reasons, there can be no concurrent > requests to your server, but that would just mean that the race is not > triggered, it’s there nevertheless. The race detector reports on races that actually happened, not races that could happen. > > Caleb

Re: [go-nuts] Hard-to-explain race detector report

2023-06-07 Thread Caleb Spare
On Wed, Jun 7, 2023 at 7:05 AM Ian Lance Taylor wrote: > > On Tue, Jun 6, 2023 at 4:31 PM Caleb Spare wrote: > > > > Can someone explain why the following test shows a race between the > > indicated lines? > > > > https://github.com/cespare/misc/blob/b2e2

[go-nuts] Hard-to-explain race detector report

2023-06-06 Thread Caleb Spare
Can someone explain why the following test shows a race between the indicated lines? https://github.com/cespare/misc/blob/b2e201dfbe36504c88e521e02bc5d8fbb04a4532/httprace/httprace_test.go#L12-L43 The race seems to be triggered by the very last line of the test: get(client1) If I comment that

Re: [go-nuts] Re: [security] Go 1.19.3 and Go 1.18.8 are released

2022-11-02 Thread Caleb Spare
Hmm, I do see a matching checksum (6d38668862bf9772c0c1c1e0f26aa5dedea9825b33f763b81ccc4aa63df2cef9) for go1.18.8.windows-amd64.msi. On Tue, Nov 1, 2022 at 10:28 AM Wojciech Kaczmarek wrote: > > I think it's important to report that go1.18.8.windows-amd64.msi doesn't > match the published

Re: [go-nuts] Re: Replacement for net.Error.Temporary in server Accept loops

2022-04-21 Thread Caleb Spare
On Thu, Apr 21, 2022 at 7:16 AM 'Bryan C. Mills' via golang-nuts wrote: > > Even ENFILE and EMFILE are not necessarily blindly retriable: if the process > has run out of files, it may be because they have leaked (for example, they > may be reachable from deadlocked goroutines). > If that is the

Re: [go-nuts] Re: Replacement for net.Error.Temporary in server Accept loops

2022-04-21 Thread Caleb Spare
On Wed, Apr 20, 2022 at 6:46 PM 'Damien Neil' via golang-nuts wrote: > > The reason for deprecating Temporary is that the set of "temporary" errors > was extremely ill-defined. The initial issue for https://go.dev/issue/45729 > discusses the de facto definition of Temporary and the confusion

[go-nuts] Replacement for net.Error.Temporary in server Accept loops

2022-04-20 Thread Caleb Spare
In Go 1.18 net.Error.Temporary was deprecated (see https://go.dev/issue/45729). However, in trying to remove it from my code, I found one way in which Temporary is used for which there is no obvious replacement: in a TCP server's Accept loop, when deciding whether to wait and retry an Accept

Re: [go-nuts] Linux, unix.Capset, and runtime.LockOSThread

2020-02-18 Thread Caleb Spare
Thanks for the reply. On Fri, Feb 14, 2020 at 8:33 PM Ian Lance Taylor wrote: > > On Thu, Feb 13, 2020 at 1:14 PM Caleb Spare wrote: > > > > Hi! I have a Linux-specific question about capabilities, threads, and > > syscalls. > > > > I have a Go program whi

[go-nuts] Linux, unix.Capset, and runtime.LockOSThread

2020-02-13 Thread Caleb Spare
Hi! I have a Linux-specific question about capabilities, threads, and syscalls. I have a Go program which runs other programs with specific capabilities set. It basically does the following: cmd := exec.Command(...) runtime.LockOSThread() unix.RawSyscall(unix.CAPSET, ...) cmd.Start()

Re: [go-nuts] What is the meaning of the "go" line in go.mod

2019-12-11 Thread Caleb Spare
There is ongoing discussion here: https://github.com/golang/go/issues/30791 Unfortunately it has been taking way too long for this to get documented. People are spending a lot of time debating what the go directive should be in go.mod files in their projects because there is no official

[go-nuts] Re: Symlink warnings in 'go mod' tool output

2019-12-02 Thread Caleb Spare
I ended up filing https://github.com/golang/go/issues/35941. On Wed, Nov 27, 2019 at 4:26 PM Caleb Spare wrote: > > I'm experimenting with converting a large source tree into a Go > module. This went pretty smoothly. However, I'm wondering why 'go mod > tidy' and 'go mod why' pr

[go-nuts] Symlink warnings in 'go mod' tool output

2019-11-27 Thread Caleb Spare
I'm experimenting with converting a large source tree into a Go module. This went pretty smoothly. However, I'm wondering why 'go mod tidy' and 'go mod why' print warnings about symlinks. These look like: $ go mod tidy warning: ignoring symlink /path/to/some/symlink/dir ... Where a warning line

Re: [go-nuts] Why not put contexts in structs?

2019-09-26 Thread Caleb Spare
You can read some more discussion about this recommendation at https://github.com/golang/go/issues/22602. (That's where I propose relaxing it somewhat, since I think the current phrasing is too strict.) On Tue, Sep 24, 2019 at 7:42 PM wrote: > > I've read the documentation recommended never to

Re: [go-nuts] Re: Go documentation - how to determine what implements an interface?

2019-05-15 Thread Caleb Spare
To summarize, there are three main concrete types in the standard library that provide ReadSeeker functionality: *os.File *bytes.Reader *strings.Reader On Wed, May 15, 2019 at 12:33 PM Sam Mortimer wrote: > > There is guru >

[go-nuts] Adding &&= and ||= operators for working with bools

2019-01-05 Thread Caleb Spare
Sometimes when working with bools I wish I could write myBool &&= x rather than myBool = myBool && x I believe that && and || are the only binary operators in the language for which the assignment form makes sense but doesn't exist (i.e., we have +=, &^=, >>=, and so on). So in some sense

Re: [go-nuts] Type inference in non-constant shift expressions

2018-12-30 Thread Caleb Spare
On Sun, Dec 30, 2018 at 12:05 PM Ian Lance Taylor wrote: > On Sat, Dec 29, 2018 at 11:12 PM Caleb Spare wrote: > > > > I noticed the following: > > > > package main > > > > func main() { > > x := float64(1 << 3) // fine (constant expr

[go-nuts] Type inference in non-constant shift expressions

2018-12-29 Thread Caleb Spare
I noticed the following: package main func main() { x := float64(1 << 3) // fine (constant expression) v := uint(3) x = float64(1 << v) // invalid operation: 1 << uint(v) (shift of type float64) _ = x } (playground: https://play.golang.org/p/xMhEvyMw0wg) It's clear from the spec why the

[go-nuts] Re: HTTP client CheckRedirect behavior for the first redirect

2018-11-17 Thread Caleb Spare
is the redirect response which caused this request // to be created. This field is only populated during client // redirects. So the response to via[0] (first redirect) is via[1].Response, and the response to via[len(via)-1] (last redirect) is req.Response. On Fri, Nov 16, 2018 at 7:43 PM Caleb Spare wrote

[go-nuts] HTTP client CheckRedirect behavior for the first redirect

2018-11-16 Thread Caleb Spare
It seems like http.Client's CheckRedirect hook only populates the via[n].Response for n>0 (i.e., not for the first hop). This is useful if, for instance, you want to check the status code (301, 302, etc) of each redirect. Here's a playground demo: https://play.golang.org/p/cKoWVhdjKwf I can file

[go-nuts] Modules + go get

2018-09-10 Thread Caleb Spare
What's the best substitute for "go get my/tool" in a modules world? I used to be able to tell my users to set up Go with a GOPATH workspace and then run "go get -u github.com/my/package". I can't find an equivalent workflow now. The closest I can find is GOBIN=~/bin GO111MODULES=on go get

Re: [go-nuts] Re: Generics as builtin typeclasses

2018-09-06 Thread Caleb Spare
On Thu, Sep 6, 2018 at 9:54 AM Ian Lance Taylor wrote: > > On Thu, Sep 6, 2018 at 8:20 AM, wrote: > > > > As I wasn't happy with some aspects of it, I've rewritten my feedback on the > > Go 2 Generics draft and deleted the original gist. Here's the link to the > > new gist for anybody who's

Re: [go-nuts] os.StartProcess equivalent for exec (without fork)?

2018-08-21 Thread Caleb Spare
, 2018 at 3:15 PM Ian Lance Taylor wrote: > > On Tue, Aug 21, 2018 at 12:49 AM, Caleb Spare wrote: > > > > I was recently trying to write a Go program that's something like chpst or > > setpriv: it execs another program with an altered process state by changing >

Re: [go-nuts] Re: os.StartProcess equivalent for exec (without fork)?

2018-08-21 Thread Caleb Spare
On Tue, Aug 21, 2018 at 3:09 PM Manlio Perillo wrote: > On Wednesday, August 22, 2018 at 12:06:15 AM UTC+2, Manlio Perillo wrote: >> >> On Tuesday, August 21, 2018 at 9:50:23 AM UTC+2, Caleb Spare wrote: >>> >>> > > [...] > > >> >>> >

Re: [go-nuts] Re: os.StartProcess equivalent for exec (without fork)?

2018-08-21 Thread Caleb Spare
On Tue, Aug 21, 2018 at 3:06 PM Manlio Perillo wrote: > On Tuesday, August 21, 2018 at 9:50:23 AM UTC+2, Caleb Spare wrote: >> >> I was recently trying to write a Go program that's something like chpst >> or setpriv: it execs another program with an altered process state by

[go-nuts] os.StartProcess equivalent for exec (without fork)?

2018-08-21 Thread Caleb Spare
I was recently trying to write a Go program that's something like chpst or setpriv: it execs another program with an altered process state by changing the user ID or modifying the ambient capabilities. (My program is Linux-specific.) In Go, when you want to spawn another process (fork+exec in

Re: [go-nuts] tests for variadic functions

2018-05-23 Thread Caleb Spare
The struct field should be vals []int and then you'd call max(test.vals...).​ On Wed, May 23, 2018 at 4:09 PM Alex Dvoretskiy wrote: > How do you write test for variadic functions? > > For example I have function: > > func max(vals ...int) int { > m := 0 > for _, v :=

Re: [go-nuts] implementation of sync.atomic primitives

2018-03-20 Thread Caleb Spare
At risk of causing more confusion, here's my understanding of the situation after observing a lot of discussion about the memory model over the years. There are at least two different things one might mean when referring to the Go memory model: 1. The written contract as specified by the

Re: [go-nuts] How to interpret runtime._ExternalCode in a profile?

2018-02-26 Thread Caleb Spare
I went ahead and optimistically filed https://github.com/golang/go/issues/24142. On Mon, Feb 26, 2018 at 2:35 PM, Caleb Spare <cesp...@gmail.com> wrote: > I think that CL that would have helped me realize it was (probably) > time.Now sooner. It certainly seems like a Pareto

Re: [go-nuts] How to interpret runtime._ExternalCode in a profile?

2018-02-26 Thread Caleb Spare
gt; > > Caleb: what do you think of https://golang.org/cl/97315? Would that have > helped with your original problem? > > Ian > > > > >> >> >> >>> >>> On Monday, 26 February 2018 14:02:13 UTC+11, Caleb Spare wrote: >>>> >>>> On a hunch, I

Re: [go-nuts] Experience report on coming to Go from a C perspective

2018-02-22 Thread Caleb Spare
I occasionally run into this, but in my experience it's exclusively with maps: - Initializing empty slices is ~never necessary; (in my opinion the "members: []int{}" from the blog post is a code smell). - Channels need initialization but that's where the important buffered vs. unbuffered choice

[go-nuts] get_tls macro and friends

2018-01-24 Thread Caleb Spare
Quick question about the Go assembler. I'm trying to use the get_tls and related macros mentioned near the bottom of https://golang.org/doc/asm. Although the line # include "go_asm.h" doesn't give an error, subsequent lines where I use the macro fail: get_tls(CX) // unrecognized instruction

Re: [go-nuts] turning a /proc/$pid/stat startTime into "seconds since this process started"

2018-01-18 Thread Caleb Spare
You can do it with cgo. I have some code that does this: // #include import "C" func init() { clockTicksPerSec = float64(C.sysconf(C._SC_CLK_TCK)) if clockTicksPerSec != 100 { log.Println("Unusual _SC_CLK_TCK value:", clockTicksPerSec) } } var

Re: [go-nuts] The o.done access on the once.Do function

2017-12-29 Thread Caleb Spare
> I believe that program will always print 2, however when you bring multiple > Goroutines into the mix, I’m less sure. I'm using examples without goroutines because the crux of our discussion, as I understand it, is whether a plain read ('if o.done == 0') will read the result of an atomic write

Re: [go-nuts] The o.done access on the once.Do function

2017-12-28 Thread Caleb Spare
>> This expression: >> >> atomic.StoreUint32(, 1) >> >> does not just take the address of o.done. It also executes the >> StoreUint32 function, which is defined by the sync/atomic >> documentation to behave like '*o.done = 1'; i.e., it alters the value >> of o.done. > > > Respectfully I disagree,

Re: [go-nuts] The o.done access on the once.Do function

2017-12-28 Thread Caleb Spare
> My argument is all that 'happens-before' is a comparison of o.done == > 0 happens before the address of o.done is passed to > atomic.StoreUint32. The rest is just luck. This expression: atomic.StoreUint32(, 1) does not just take the address of o.done. It also executes the StoreUint32

Re: [go-nuts] The o.done access on the once.Do function

2017-12-28 Thread Caleb Spare
My argument is made without reference to registers, liveness, inlining, or any of that. The memory model defines certain behavior of mutexes (intuitively, it's how you think they would work) and sync/atomic defines how StoreUint32 behaves (it's some atomic version of *o.done = 1). (There are

Re: [go-nuts] The o.done access on the once.Do function

2017-12-28 Thread Caleb Spare
I'm quite certain that code is correct. There's no data race here since the write and the non-atomic read are both inside the mutex. The memory model rules about mutexes formalize how they serialize the code inside them. Because the unlock happens-before the next lock, and because sequential code

Re: [go-nuts] base32 DecodeLen() miscalculation when no padding

2017-12-13 Thread Caleb Spare
And in fact, Tv has already done that. You want https://github.com/tv42/zbase32. On Wed, Dec 13, 2017 at 3:01 AM, roger peppe wrote: > On 13 December 2017 at 01:23, Ian Lance Taylor wrote: >> On Tue, Dec 12, 2017 at 3:13 PM, Jeffrey Goldberg

Re: [go-nuts] Simple exec.Command() program

2017-11-12 Thread Caleb Spare
ls is a bash builtin. You can probably invoke the ls command with /bin/ls. But also, passing ">" as an argument to exec.Command doesn't do what you want. > is a redirection for a shell and exec.Command is not a shell. I'm not sure what you're trying to accomplish, but here are two things you

Re: [go-nuts] Starting an HTTP server and logging about it

2017-11-09 Thread Caleb Spare
I always just go with (1). This problem occurs to me and always bugs me a little, but I file it under "issues the day is too short to worry about". In practice when you see this in the logs starting server on port 4567 it's clear enough what happened. On Thu, Nov 9, 2017 at 12:16 PM, Kevin

Re: [go-nuts] newbie trying unusual sort

2017-11-07 Thread Caleb Spare
You could define multiple types: type bySubtotal []directory type byName []directory which have different Sort methods. You could also define a type that includes a func(d0, d1 directory) bool. The SortKeys example in the sort package docs (https://golang.org/pkg/sort/#example__sortMultiKeys)

Re: [go-nuts] Debugging a mutex/scheduling issue

2017-10-16 Thread Caleb Spare
no goroutine has the lock is large. On Mon, Oct 16, 2017 at 1:13 PM, Ian Davis <m...@iandavis.com> wrote: > This sounds like https://github.com/golang/go/issues/13086 > > On Mon, 16 Oct 2017, at 09:01 PM, Caleb Spare wrote: >> I have a server which is doing log processing and I'm

[go-nuts] Debugging a mutex/scheduling issue

2017-10-16 Thread Caleb Spare
I have a server which is doing log processing and I'm trying to improve throughput. The bottleneck is access to a shared resource protected by a sync.Mutex. The issue is that even though there are nearly always worker goroutines blocked on Lock, only about 10% of the time (in aggregate) is spent

Re: [go-nuts] Bug: gofmt 1.9 can't handle go 1.9 code

2017-08-29 Thread Caleb Spare
Works for me locally. I use both gofmt and goimports; for the latter, I had to recompile it. https://github.com/golang/go/issues/21645 is about updating the playground. On Tue, Aug 29, 2017 at 9:05 PM, Tong Sun wrote: > > > On Wednesday, August 30, 2017 at 12:02:28 AM

Re: [go-nuts] Re: go 1.9: New Helper() method in testing package does not work with testing.TB interface

2017-08-25 Thread Caleb Spare
That's not a mistake. It's still a bug! Just doesn't seem like a very severe one. I filed https://github.com/golang/go/issues/21631. On Fri, Aug 25, 2017 at 3:08 PM, lukas.malkmus via golang-nuts < golang-nuts@googlegroups.com> wrote: > I'm sorry, I think I made a huge mistake. The malicious

Re: [go-nuts] Re: go 1.9: New Helper() method in testing package does not work with testing.TB interface

2017-08-25 Thread Caleb Spare
Yeah, sorry, I misread the report. I can't reproduce the issue. Can you give a complete runnable example. On Fri, Aug 25, 2017 at 1:46 PM, lukas.malkmus via golang-nuts < golang-nuts@googlegroups.com> wrote: > It is part of the interface... > > > Am Freitag, 25. August 2017 22:35:21 UTC+2

Re: [go-nuts] go 1.9: New Helper() method in testing package does not work with testing.TB interface

2017-08-25 Thread Caleb Spare
I filed https://github.com/golang/go/issues/21627. Thanks for the heads up. On Fri, Aug 25, 2017 at 1:39 PM, Caleb Spare <cesp...@gmail.com> wrote: > Oh, shoot. It should be part of the interface. That was part of the > proposal: > > https://github.com/golang/proposal/blob/mas

Re: [go-nuts] go 1.9: New Helper() method in testing package does not work with testing.TB interface

2017-08-25 Thread Caleb Spare
Oh, shoot. It should be part of the interface. That was part of the proposal: https://github.com/golang/proposal/blob/master/design/4899-testing-helper.md but I forgot to add it. On Fri, Aug 25, 2017 at 1:16 PM, lukas.malkmus via golang-nuts < golang-nuts@googlegroups.com> wrote: > I'm using

Re: [go-nuts] Is everything passed as a value in Go?

2017-04-18 Thread Caleb Spare
The fact that https://github.com/golang/go/issues/5083 still hasn't been sorted out means that it's hard to explain this to people using officially sanctioned terminology. I usually end up just using the phrase "reference types" along with some further description of what I mean (in particular to

Re: [go-nuts] Teaching Elementary/Middle School Kids?

2017-04-11 Thread Caleb Spare
I don't think it's off-topic. This ML is about pretty much anything Go-related. We've had discussions about teaching Go to kids before. On Tue, Apr 11, 2017 at 10:26 AM, Bala Natarajan wrote: > I did not realize that this was off-topic. My mistake. > > Thanks David

Re: [go-nuts] Re: Go 1.8.1 is released

2017-04-09 Thread Caleb Spare
You probably need to rebuild dependencies. (go build -i / go test -i / go install) On Sun, Apr 9, 2017 at 6:52 PM, sachin walia wrote: > Thanks for releasing update so quickly. I've noticed that my build time has > increased in 1.8.1 compared to 1.8. Is it a regression

Re: [go-nuts] Syscalls inside loops + runtime.KeepAlive

2017-04-05 Thread Caleb Spare
Thanks, Ian. On Wed, Mar 29, 2017 at 1:03 PM, Ian Lance Taylor <i...@golang.org> wrote: > On Wed, Mar 29, 2017 at 9:42 AM, Caleb Spare <cesp...@gmail.com> wrote: >> I have a question about this runtime.KeepAlive call: >> >>

Re: [go-nuts] Is it harmful to always return invalid values on a non-nil-error?

2017-04-03 Thread Caleb Spare
Hey Axel, this is a good question that I've thought about from time to time as well. It seems that most people in this thread have misunderstood it :) I personally agree with your preference as given in the examples just because I find the code easier to read when the error return is handled

[go-nuts] Syscalls inside loops + runtime.KeepAlive

2017-03-29 Thread Caleb Spare
I have a question about this runtime.KeepAlive call: https://github.com/golang/go/blob/041ecb697f0e867a2bb0bf219cc2fd5f77057c2e/src/os/dir_unix.go#L68 (There are other examples in the stdlib as well, I think.) It seems to me that, strictly speaking, KeepAlive is unnecessary here since the

Re: [go-nuts] Re: Unsafe string/slice conversions

2017-03-23 Thread Caleb Spare
Filed: https://github.com/golang/go/issues/19687 On Thu, Mar 23, 2017 at 4:41 PM, 'Keith Randall' via golang-nuts <golang-nuts@googlegroups.com> wrote: > > > On Thursday, March 23, 2017 at 4:24:40 PM UTC-7, Caleb Spare wrote: >> >> That's very good to know. Thanks, Ia

[go-nuts] Re: Unsafe string/slice conversions

2017-03-23 Thread Caleb Spare
in general? Caleb On Thu, Mar 23, 2017 at 10:26 AM, Ian Lance Taylor <i...@golang.org> wrote: > On Thu, Mar 23, 2017 at 9:16 AM, Caleb Spare <cesp...@gmail.com> wrote: >> >> Brief follow-up: does the seeming validity of the code rely at all on >> the fact that the indi

[go-nuts] Re: Unsafe string/slice conversions

2017-03-23 Thread Caleb Spare
an Lance Taylor <i...@golang.org> wrote: > On Tue, Feb 21, 2017 at 2:53 PM, Caleb Spare <cesp...@gmail.com> wrote: >> I have a program that uses unsafe in order to coerce some slices to >> strings for use as map keys. (Avoiding these allocations ends up being >> an im

Re: [go-nuts] Handle gziped request bodies

2017-03-04 Thread Caleb Spare
You'll need to handle it yourself. Gzipped requests (unlike responses) are somewhat nonstandard. (With a response, the client can say it supports gzip, but with requests, you basically have to prenegotiate it out-of-band -- at least, that's how I've encountered it in the past.) On Mar 4, 2017

Re: [go-nuts] How do I convert a byte into BigEndian or LittleEndian?

2017-02-27 Thread Caleb Spare
What do you mean by the endianness of a single byte? Endianness is about the order of a sequence of bytes. On Mon, Feb 27, 2017 at 1:45 PM, Glen Newton wrote: > > > Given a byte b, how do I convert it to a byte of particular endianness? > It is not clear to me looking at

Re: [go-nuts] Monotonic clock: is my code affected?

2017-02-27 Thread Caleb Spare
I don't think the behavior of that code changes. (t.Hour, etc operate on wall time; t.Add operates on both wall and monotonic time.) If I wanted to truncate times to hours, though, I would write code like this: https://play.golang.org/p/el8hUeXpWK On Mon, Feb 27, 2017 at 3:25 AM, Olivier Mengué

Re: [go-nuts] Re: Unsafe string/slice conversions

2017-02-23 Thread Caleb Spare
That only applies to []byte. I have a []uint64. On Feb 23, 2017 4:13 AM, "T L" <tapir@gmail.com> wrote: > > > On Wednesday, February 22, 2017 at 6:53:53 AM UTC+8, Caleb Spare wrote: >> >> I have a program that uses unsafe in order to coerce some sli

[go-nuts] Unsafe string/slice conversions

2017-02-21 Thread Caleb Spare
I have a program that uses unsafe in order to coerce some slices to strings for use as map keys. (Avoiding these allocations ends up being an important performance optimization to this program.) Here's some example code that shows what I'm doing: https://play.golang.org/p/Yye1Riv0Jj Does this

Re: [go-nuts] flag: possible issue with intValue.Set

2017-02-21 Thread Caleb Spare
Like unsafe.Sizeof? On Tue, Feb 21, 2017 at 1:56 PM, Manlio Perillo wrote: > Il giorno martedì 21 febbraio 2017 22:14:38 UTC+1, Ian Lance Taylor ha > scritto: >> >> On Tue, Feb 21, 2017 at 9:51 AM, Manlio Perillo >> wrote: >> > I have noted that

Re: go test -race much slower in 1.8 (was Re: [go-nuts] Go 1.8 is released)

2017-02-20 Thread Caleb Spare
Hey Will, it might help to get timings for just -race and -coverprofile (not both) to try to isolate timing increase a bit. On Mon, Feb 20, 2017 at 12:23 PM, Ian Lance Taylor wrote: > On Mon, Feb 20, 2017 at 12:06 PM, Will Newton wrote: >> On Thu, Feb 16,

Re: [go-nuts] Re: Is there a reason go doesn't use the small string optomization

2017-02-01 Thread Caleb Spare
Your document is not accessible to me. (Google-internal?) On Wed, Feb 1, 2017 at 5:18 PM, 'Keith Randall' via golang-nuts wrote: > I wrote up a proto-proposal for something like this a while ago. > >

Re: [go-nuts] Is Go too strict for nesting function callings?

2017-01-25 Thread Caleb Spare
https://golang.org/ref/spec#Calls Look for "As a special case, if the return values of a function or method g are equal in number" On Wed, Jan 25, 2017 at 4:42 PM, John Souvestre wrote: > Then I'm still confused. Where is this inconsistency / limitation / > non-orthogonal

Re: [go-nuts] bit twiddling API survey

2017-01-09 Thread Caleb Spare
Hi! This is great stuff. I've written a few asm loops in order to use bit-twiddling instructions. The ones you listed cover all of those. One other thing to consider is rotate. The compiler does a good job of recognizing constant rotates and it's getting better

Re: [go-nuts] Re: locks and "happens before" withing a goroutine

2016-11-30 Thread Caleb Spare
I think the bit you're missing is this: > Within a single goroutine, the happens-before order is the order expressed by > the program. That is, there is an implicit happens-before between each successive statement *within a single goroutine*. So in the example: - the first l.Lock()

[go-nuts] Avoiding function call overhead in packages with go+asm implementations

2016-11-17 Thread Caleb Spare
I've run into an annoying problem. I'm not sure if there's a solution I've overlooked and I'm hoping you folks have some ideas for me. I have a library that provides a function Sum64(b []byte) uint64. I have both asm and pure-go implementations of this function, and I want both to be as fast as

Re: [go-nuts] Enforcing decimal output when using json.Encode

2016-11-16 Thread Caleb Spare
> So my question is: Prior to go 1.8's release, how can we force float64 > values to be output in decimal? This is a problem for me specifically > because our mobile user's report their lat/lon with six places of precision. > Trying to dump that output to JSON causes a bunch of unusable

Re: [go-nuts] Re: Stalking people online for thought crimes! This is what the Go project has succumbed to!

2016-10-28 Thread Caleb Spare
On Fri, Oct 28, 2016 at 2:41 PM, Aldrin Leal wrote: > Regardless, I wonder what would be the action taken if it were more than a > "warning". > > Would the CoC people issue a "SP" declaration? An Index Comunitum > Prohibitorum? Why wonder? You can read for yourself at

Re: [go-nuts] What is called reference values in Golang?

2016-10-21 Thread Caleb Spare
"goference" On Fri, Oct 21, 2016 at 10:13 AM, Ian Lance Taylor wrote: > On Fri, Oct 21, 2016 at 8:59 AM, T L wrote: >> >> Is it a good idea to remove the reference words from faq? >> Go spec did this 3 years ago. > > The question makes sense and needs an

Re: [go-nuts] allow {3}, {true} etc

2016-10-21 Thread Caleb Spare
I would also like an easier way to construct pointers to ints/bools/strings. Note that there is a way to write convoluted code that makes e.g. {3} legal: https://play.golang.org/p/leP5_12IX0 AFAICT this isn't a backwards-compatibility concern, though. Like you, I would really like &5 to work but

Re: [go-nuts] can't understand sync.RWMutex documentation

2016-10-03 Thread Caleb Spare
It's explained in the text afterwards: "This is to ensure that the lock eventually becomes available; a blocked Lock call excludes new readers from acquiring the lock." So if you RLock and then another goroutine tries to Lock, you might not be able to RLock again until the first read lock is

Re: [go-nuts] Overflow behavior guarantees for atomic.Add*

2016-10-03 Thread Caleb Spare
> I'm familiar with (and greatly appreciate!) the guarantees regarding > overflow for ordinary integer arithmetic in the Go spec Which guarantees? > but I've been > unable to locate anything that reassures me that similar guarantees apply > for the sync/atomic.Add* functions. Is there any

[go-nuts] Re: Getting a snapshot of point-in-time allocation

2016-09-29 Thread Caleb Spare
Of course now that I sent this email, I have just noticed this pprof flag: -baseShow delta from this profile I haven't tried it yet, but this seems like it might solve these problems. -Caleb On Thu, Sep 29, 2016 at 2:12 PM, Caleb Spare <cesp...@gmail.com> wrote: > pprof gives

[go-nuts] Getting a snapshot of point-in-time allocation

2016-09-29 Thread Caleb Spare
pprof gives two kinds of heap profiles: (please let me know if any of this is not correct) - inuse_space -- a profile of the currently live objects/bytes on the heap - alloc_space -- a profile of the allocated objects/bytes since program startup When I need to figure out why my heap is so big,

Re: [go-nuts] Golang package documentation: missing methods? Are they missing on purpose?

2016-09-25 Thread Caleb Spare
That's just how interfaces are rendered in Godoc. (Compare, for example, io.Reader.) Concrete types (e.g., reflect.Value) have their method docs listed explicitly. Perhaps it looks strange because reflect.Type is an extremely large interface. Most interfaces in the stdlib have about 1-3 methods.

Re: [go-nuts] How to generate a positive int64 from byte slice

2016-09-23 Thread Caleb Spare
You'll probably want to use encoding/binary. But which 8 of the 32 bytes are you going to use? (or really, which 63 bits?) -Caleb On Fri, Sep 23, 2016 at 5:25 PM, JohnGB wrote: > I have a byte slice 32 bytes long, and I would like to use it to generate a > positive int64.

Re: [go-nuts] Adding YAML to the stdlib

2016-09-23 Thread Caleb Spare
I sincerely hope we never add YAML to the stdlib, as that would increase the amount of YAML in the world. > Also, it is slightly unfair to have the expectation that the community should > support a significant format through independent OSS work. Can you explain this? I don't follow. -Caleb

Re: [go-nuts] Can concurrent part of GC still block/stall certain parts of program execution?

2016-09-23 Thread Caleb Spare
You could be experiencing https://github.com/golang/go/issues/16293. You can test this hypothesis by patching in the fix (https://github.com/golang/go/commit/cf4f1d07a189125a8774a923a3259126599e942b) yourself. That change will be released with Go 1.8. -Caleb On Fri, Sep 23, 2016 at 8:32 AM,

Re: [go-nuts] Calling a Go function from asm ("fatal error: missing stackmap")

2016-09-20 Thread Caleb Spare
Thanks very much for your reply, Ian. I had hoped this would not be the answer, though :) I think I can arrange to avoid calling from asm to Go at a minor cost. That sounds like the best solution here. Creating the stack map manually might be interesting exercise for learning about this corner

[go-nuts] Calling a Go function from asm ("fatal error: missing stackmap")

2016-09-19 Thread Caleb Spare
I'm trying to call a Go function from asm and I'm having trouble figuring out the details. (In the past I've always endeavored to avoid this situation and make all my asm functions be leaf functions, but in my current use case it would be most helpful to be able to call a Go helper.) See the

Re: [go-nuts] parsing millisecond coming after colon

2016-09-12 Thread Caleb Spare
As Dave said, you should check the error, but unfortunately I think you'll find that time.Parse doesn't handle fractional seconds that use a character other than . as a decimal separator. One possible workaround would be to replace all the : with . first: https://play.golang.org/p/h_IMQxtoVI

Re: [go-nuts] Multiple-reader single-writer map access - is this lockless workaround safe?

2016-09-12 Thread Caleb Spare
If you have a data race, you lose a lot of guarantees about the correct operation of your program. It may work today but fail occasionally, or a future version of the compiler may break it very badly. See

Re: [go-nuts] Multiple-reader single-writer map access - is this lockless workaround safe?

2016-09-12 Thread Caleb Spare
That's still a data race. Are you using the race detector? On Mon, Sep 12, 2016 at 9:04 AM, sqweek E. wrote: > Yes, through plain assignment. What problems arise from that? > > On Monday, September 12, 2016 at 11:21:05 PM UTC+8, Peter Bourgon wrote: >> >> How are you replacing

Re: [go-nuts] reading with scanner.Bytes()

2016-08-29 Thread Caleb Spare
You can do b0 := scanner.Bytes() b1 := make([]byte, len(b0)) copy(b0, b1) outChannel <- b0 On Mon, Aug 29, 2016 at 8:23 PM, chris.lu via golang-nuts wrote: > I am reading a file line by line, and send it to a chan []byte, and consume > it on another goroutine. > >

Re: [go-nuts] Speeding up multiple regexp matches

2016-07-27 Thread Caleb Spare
On Wed, Jul 27, 2016 at 9:42 AM, Andy Balholm wrote: > in github.com/andybalholm/redwood, one thing I do is to check each URL > against a (potentially very large) set of regular expressions. Since these > regular expressions generally contain fairly significant amounts of

Re: [go-nuts] callee returns nil, caller does not see nil

2016-07-01 Thread Caleb Spare
https://golang.org/doc/faq#nil_error Make Validate return error, not MultiError. -Caleb On Fri, Jul 1, 2016 at 5:04 PM, Kevin Manley wrote: > I am new to Go so I'm sure this is just me misunderstanding how things work, > but I was surprised at this result. Please can

[go-nuts] Re: GODEBUG=gctrace=1 vs. debug.GCStats

2016-06-22 Thread Caleb Spare
ight actually be 0.207ms. > > On Wed, Jun 22, 2016 at 5:55 PM, Caleb Spare <cesp...@gmail.com> wrote: >> >> Hi, >> >> I'm looking at GC statistics using both GODEBUG=gctrace=1 and >> debug.ReadGCStats. My question is: should the pause durations repor

[go-nuts] GODEBUG=gctrace=1 vs. debug.GCStats

2016-06-22 Thread Caleb Spare
Hi, I'm looking at GC statistics using both GODEBUG=gctrace=1 and debug.ReadGCStats. My question is: should the pause durations reported in debug.GCStats match the sum of the two STW phases listed in the gctrace? I ask because they are generally close but not the same. I have a trivial program