[go-nuts] Re: 1.13.4: go mod: weird permissions in pkg/mod after go get

2019-11-25 Thread 'Bryan Mills' via golang-nuts
The go/loader issue looks like https://golang.org/issue/34860 combined with some other bug in one of the go/loader error-handling paths. (Note that in general we recommend golang.org/x/tools/go/packages for Go tools that support module mode.)

Re: [go-nuts] Re: Struggling with go mod, micro-repos and private forks

2019-10-25 Thread 'Bryan Mills' via golang-nuts
On Friday, October 25, 2019 at 10:19:03 AM UTC-4, Shaun Crampton wrote: > > > > We have https://golang.org/issue/26232 open for 2FA workflows in general. >> >> In the meantime, you may need to configure a Personal Access Token >>

[go-nuts] Re: Struggling with go mod, micro-repos and private forks

2019-10-23 Thread 'Bryan Mills' via golang-nuts
Thanks for the feedback. The good news is that we're aware of (and planning to address) most of these pain points; the bad news is that we haven't been able to get to most of them yet. Detailed responses inline. On Tuesday, October 22, 2019 at 6:42:05 AM UTC-4, Shaun Crampton wrote: > > Hi All

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-08 Thread 'Bryan Mills' via golang-nuts
On Wednesday, August 7, 2019 at 4:21:03 AM UTC-4, Jan Mercl wrote: > > On Wed, Aug 7, 2019 at 3:17 AM hui zhang > > wrote: > > > //export Send > > func Send(confid string, len int, pcm *C.short) { > >//put c.short array to int16 slice/array efficiently , how ? > >// memcopy ? > > } >

[go-nuts] Re: Prevent a package from being updated using go modules

2019-07-16 Thread 'Bryan Mills' via golang-nuts
This sort of use-case is pretty much exactly what the exclude directive is for. (See https://tip.golang.org/cmd/go/#hdr-The_go_mod_file.) In your go.mod file, add a directive like: exclude github.com/vendor/package v1.3.0 In the meantime, send a PR or file an issue with github.com/vendor/packag

Re: [go-nuts] The "leave "if err != nil" alone?" anti-proposal

2019-07-02 Thread 'Bryan Mills' via golang-nuts
On Monday, July 1, 2019 at 3:12:24 AM UTC-4, Ian Lance Taylor wrote: > > Think about how you would write a basic Go construct like > https://godoc.org/golang.org/x/sync/errgroup if errors are handled via > exceptions. I'm not saying you can't do it--of course you can do it. > But it seems to me

[go-nuts] go version go1.12 and cannot find module providing package

2019-05-31 Thread 'Bryan Mills' via golang-nuts
The highest release tag on that module is v0.0.2, and that version indeed does not provide the clis package. If you want a commit that is more recent than the latest release, you need to request that commit to 'go get' explicitly. -- You received this message because you are subscribed to the

[go-nuts] How to properly release a new project as a V2 module

2019-03-02 Thread 'Bryan Mills' via golang-nuts
The /v2 suffix is not just for within your code: that's how you need to address the module (and import its packages) everywhere. The contents of your go.mod file suggest that your calling code, or perhaps the `go get` command you used to add the module, is missing that suffix. -- You received

[go-nuts] Re: What is the future of go mod vendoring?

2019-02-15 Thread 'Bryan Mills' via golang-nuts
Vendoring support in 1.13 is currently under discussion at https://golang.org/issue/30240. TL;DR: I'm hoping to better integrate it with the module workflow. (It's not going away in the foreseeable future.) On Friday, February 15, 2019 at 5:05:14 AM UTC-5, Amnon Baron Cohen wrote: > > > https:

Re: [go-nuts] Go modules do not respect vendor folder of dependencies (is this by design?)

2019-02-11 Thread 'Bryan Mills' via golang-nuts
The fact that a module-mode build ignores dependencies vendored into *other* modules is intentional. #27227 may change several details of vendoring in module mode, but this is not one of them. If module B vendors its dependencies but does not specify their versions in a go.mod file, then you s

Re: [go-nuts] Re: Existing code for order-preserving concurrent work queue?

2019-01-30 Thread 'Bryan Mills' via golang-nuts
The code to sequence the results using a channel is not much more verbose. That not only avoids the library dependency, but also makes the peak memory consumption for the results O(runtime.NumCPU()), instead of O(N) with the number of tasks, and allows the output to be streamed instead of buffer

[go-nuts] Re: invalid recursive type alias

2018-12-10 Thread 'Bryan Mills' via golang-nuts
The compiler is behaving as designed in both cases. See https://golang.org/issue/25187 (and the associated https://golang.org/issue/25141). On Saturday, December 8, 2018 at 12:33:48 PM UTC-5, Jan Mercl wrote: > > This code compiles fine > > package main > > type node st

Re: [go-nuts] convert *byte to []byte

2018-12-07 Thread 'Bryan Mills' via golang-nuts
On Monday, December 3, 2018 at 12:02:07 AM UTC-5, Ian Lance Taylor wrote: > > On Sat, Dec 1, 2018 at 9:39 AM > wrote: > > > > I am using swig wrap a c++ module , the generated go code is like this: > > > > type MediaFrame interface { > > GetLength() uint > > GetData() (*byte) >

Re: [go-nuts] New Modules and git clones

2018-11-14 Thread 'Bryan Mills' via golang-nuts
On Wednesday, November 14, 2018 at 2:26:07 PM UTC-5, Paul Jolly wrote: > > > > Can you point us at the documentation you're referring to here, > please? > > > > go help go.mod > > Thanks - it's honestly the first time I've a) read that help document > or b) seen the dev version format. I also

[go-nuts] Re: Mini library for structured concurrency.

2018-10-29 Thread 'Bryan Mills' via golang-nuts
(Hi, errgroup author here. Comments inline below.) On Thursday, October 25, 2018 at 7:40:43 AM UTC-4, Andrew Chambers wrote: > > @Sebastien > > The biggest difference is my package makes guarantees that when a bundle > is garbage collected the context and thus child goroutines > are cancelled. Th

Re: [go-nuts] efficient way to csv.Reader() from a chan of string

2018-09-17 Thread 'Bryan Mills' via golang-nuts
You don't need the io.Pipe: it's fairly trivial to implement io.Reader in terms of a channel of strings and a strings.Reader. You can even implement io.WriterTo efficiently that way: https://play.golang.org/p/PxIEQYUoC50 (In theory that can make the whole pipeline zero-copy, but in practice I

Re: [go-nuts] Why can't we use unicode? [Go2 Generics]

2018-09-13 Thread 'Bryan Mills' via golang-nuts
Coincidentally, I contribute to a ChromeOS extension that adds XCompose support,¹ and I use a similar utility on Windows.² (I'm not sure what's available on macOS.) ¹ https://github.com/bcmills/extra-keyboards-for-chrome-os/tree/custom-sequences ² https://github.com/samhocevar/wincompose On Frid

[go-nuts] Re: Go 1.11 module cache not safe for concurrent use?

2018-09-13 Thread 'Bryan Mills' via golang-nuts
The module cache and the build cache are separate entities. The build cache is safe for concurrent use. The module cache is not (yet),¹ but you can pre-populate it by running go mod download. ¹ https://golang.org/issue/26794 On Tuesday, August 28, 2018 at 11:01:43 AM UTC-4, Maxim Khitrov wrote

[go-nuts] Re: Go modules: go get installs binary

2018-09-12 Thread 'Bryan Mills' via golang-nuts
Per the documentation , “Get resolves and adds dependencies to the current development module and then builds and installs them.” If you want it to only update dependencies, use the -m flag; to only update and download, use -d. On Sunda

[go-nuts] Re: Go 1.11 Beta 3 is released

2018-08-09 Thread 'Bryan Mills' via golang-nuts
Did you happen to install it using another go1.11 beta build in module mode? If so, it could have been https://golang.org/issue/26869. On Thursday, August 9, 2018 at 4:35:31 PM UTC-4, Ken MacDonald wrote: > > Hi, > Just attempted to install 1.11beta3. Using the following instructions, the > "go

Re: [go-nuts] Go could really use a while statement

2018-05-08 Thread 'Bryan Mills' via golang-nuts
On Thursday, May 3, 2018 at 4:25:34 AM UTC-4, rog wrote: > > FWIW, the thing I miss sometimes is the equivalent of C's: > > while((x = next()) != nil) { > something() > } > > In Go you need to do either: > > for x = next(); x != nil; x = next() { > something()

[go-nuts] Re: On Accepting Interfaces and Structs

2018-04-23 Thread 'Bryan Mills' via golang-nuts
I agree with Jake: a more complete example would be helpful. In my experience, this sort of issue is often a symptom of awkward package boundaries. If you can find a more natural package boundary, you may be able to sidestep the problem. (There are certainly some cases where the lack of covaria

Re: [go-nuts] Re: Is there a memory leak on Rob Pike's demo codes?

2018-04-05 Thread 'Bryan Mills' via golang-nuts
To answer the original question about how to detect the leak: if you have a leak, the “goroutine” profile from runtime/pprof will show an ever-increasing number of goroutines with the same stack trace. Detecting such a leak in a unit or integratio

[go-nuts] Re: panic propagation can be blocked by blocking defer function

2018-04-02 Thread 'Bryan Mills' via golang-nuts
This is indeed a subtle pattern, but it's not clear to me how often it comes up in practice, and preventing deferred function calls from blocking could result in all kinds of other unwanted side effects. I'm curious: how did you end up with the `wg.Add` call so far from the deferred `Wait`, and

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

2018-02-22 Thread 'Bryan Mills' via golang-nuts
You might be interested in https://golang.org/issue/12854 for maps, slices, and structs. (It wouldn't help with channels, because there is currently no such thing as a channel literal.) On Thursday, February 22, 2018 at 5:32:40 PM UTC-5, Devon H. O'Dell wrote: > > 2018-02-22 14:19 GMT-08:00 Cal

Re: [go-nuts] context.Context and worker pools

2018-02-16 Thread 'Bryan Mills' via golang-nuts
Pool the resources, not the workers. For example, if your resource is “memory footprint of in-flight requests”, use a semaphore instead. (There is a “worker pool” example in the package docs.) If your resource is a fixed-size set of connections, y

Re: [go-nuts] Re: How to pass Go []byte (arrays/slices) as C *char to C functions

2018-01-24 Thread 'Bryan Mills' via golang-nuts
It may be considerably more efficient to pass the Go pointers directly. To do so, you may need to convert through unsafe.Pointer. Note that many C APIs that take a char* expect it to be null-terminated, so if you take that approach you may need to append an extra 0 to the slice. https://golang.o

Re: [go-nuts] Is it reasonable?

2018-01-08 Thread 'Bryan Mills' via golang-nuts
On Sunday, January 7, 2018 at 6:09:45 AM UTC-5, Jan Mercl wrote: > > On Sun, Jan 7, 2018 at 11:57 AM T L > > wrote: > > Yes. The choice is to raise a runtime error or not. When not, the value > does not really matter because every value of an integer variable > represents an integer number and t

Re: [go-nuts] Channels vs Callbacks in API

2018-01-02 Thread 'Bryan Mills' via golang-nuts
In some cases, a synchronous callback can be a fine choice: consider filepath.Walk . A synchronous callback does not require any extra goroutines, and if the caller needs to adapt it to work with a channel (or perform longer-duration processing in

[go-nuts] Re: Sending C array over gob ; decoding shows wrong data

2017-12-19 Thread 'Bryan Mills' via golang-nuts
Per https://golang.org/pkg/encoding/gob/, “Structs encode and decode only exported fields.” The fields of your C struct are unexported in Go, since they start with lower-case letters. If the gob package is encoding or decoding the non-array fields of the struct, *that* is the bug. On Monday,

[go-nuts] Re: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread 'Bryan Mills' via golang-nuts
In this case, the vet tool is correct if you're making the syscall with Go-allocated memory. The Go runtime is allowed to move values around: the address of a Go variable is only pinned for the duration of the syscall itself. If you've got C-allocated memory (or statically-allocated memory), ht

[go-nuts] Re: Should an empty append be an error ?

2017-12-04 Thread 'Bryan Mills' via golang-nuts
The spec defines `append` as a variadic function, with a type of the form append(s S, x ...T) S // T is the element type of S Variadic functions, in general, accept zero or more parameters. (Consider fmt.Println().) In order to reject empty appends, append would either have to have its own s

Re: [go-nuts] chan chan Job per worker vs. single chan Job

2017-11-28 Thread 'Bryan Mills' via golang-nuts
Why have long-lived worker goroutines at all? If you're just trying to limit the number of jobs in flight, a semaphore is usually simpler. (A `chan struct{}` or `chan bool` works fine as a simple semaphore; for more complex use-cases, there are several semaphore packages on godoc.org. Personall

[go-nuts] Re: How to convert from []byte to []uint32?

2017-11-13 Thread 'Bryan Mills' via golang-nuts
Yes, it looked like a typo to me. Truncating the string to an even number of characters gives the same results as the original snippet: https://play.golang.org/p/avf6xqnpEn It's also not difficult to pad the input, if that's the desired behavior: https://play.golang.org/p/Q6C9SBhQB5 (Padding wit

[go-nuts] Re: How to convert from []byte to []uint32?

2017-11-13 Thread 'Bryan Mills' via golang-nuts
In this case, the "code golf" solution seems clearer: https://play.golang.org/p/Jxkf2Vheml On Monday, November 13, 2017 at 3:57:57 PM UTC-8, peterGo wrote: > > Christian, > > Your specialized convertCharToInt32 function, which returns []uint32, is > slow in comparison to a more general HexToUint

[go-nuts] Re: NaN as key in map

2017-11-10 Thread 'Bryan Mills' via golang-nuts
On Friday, November 10, 2017 at 5:24:25 PM UTC-5, Stefan Nilsson wrote: > > NaN is not equal to NaN. This means that if you use NaN as a key in a > map[float64]string you will not be able to retrieve it again: > https://play.golang.org/p/A7KGgoM3o6 > I guess this is the way it should be, but it's

Re: [go-nuts] cgo style question

2017-11-03 Thread 'Bryan Mills' via golang-nuts
I have argued that there ought to be a standard function for this. There is a proposal to add a simpler API for manipulating slice headers directly, but it is labeled Go 2. In the meantime, see this comment

Re: [go-nuts] is this code thread safety?

2017-11-03 Thread 'Bryan Mills' via golang-nuts
In general you can use the race detector to help answer this sort of question, although it does not detect all races. Unfortunately, it doesn't detect this one. (I've filed https://golang.org/issue/22569, because I think it should.) On Friday, November 3, 2017 at 4:08:19 AM UTC-4, sheepbao wrot

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2017-11-01 Thread 'Bryan Mills' via golang-nuts
On Wednesday, November 1, 2017 at 10:32:21 AM UTC-4, Ian Lance Taylor wrote: > > On Wed, Nov 1, 2017 at 4:18 AM, > wrote: > > > > Ayan, imagine I am part of a development team. In our program I have a > > pointer r: > > > > r *myType > > > > My variable r can be nil, because that is a valid

[go-nuts] Re: Make error handling less verbose with Zig %% operator and %return expression?

2017-10-17 Thread 'Bryan Mills' via golang-nuts
There are lots of similar proposals in the issue tracker. Of those, https://golang.org/issue/21161 seems to have the most traffic. On Tuesday, October 17, 2017 at 5:09:33 PM UTC-4, Nicolas Grilly wrote: > > I just read about Zig, a new programming language designed to replace C. > > The error hand

[go-nuts] Re: Compile-time parameters in Zig: a possible solution to generic functions and data structures in Go?

2017-10-17 Thread 'Bryan Mills' via golang-nuts
On Tuesday, October 17, 2017 at 4:52:55 PM UTC-4, Nicolas Grilly wrote: > > Hello, > > I just read about the concept of compile-time parameters in Zig (a new > programming language designed to replace C): > > > http://andrewkelley.me/post/zig-programming-language-blurs-line-compile-time-run-time.h

Re: [go-nuts] Re: concurrent write-only to map ok?

2017-10-16 Thread 'Bryan Mills' via golang-nuts
On Sunday, October 15, 2017 at 1:45:06 PM UTC-4, Alex Buchanan wrote: > > Show me the code! :) > > Here's mine: https://play.golang.org/p/ZwAlu5VuYr > The problem that sync.Map is intended to address is cache contention. Unfortunately, it doesn't currently address that problem well for stores of

Re: [go-nuts] Sync pool old data

2017-10-12 Thread 'Bryan Mills' via golang-nuts
On Wednesday, October 11, 2017 at 4:03:30 PM UTC-4, Ian Lance Taylor wrote: > > if the number of parallel operations does not vary > significantly, a freelist is a simpler and more effective technique. > A freelist might be simpler, but it isn't necessarily more effective. sync.Pool combines tw

Re: [go-nuts] when to use Sync pool

2017-10-09 Thread 'Bryan Mills' via golang-nuts
On Friday, October 6, 2017 at 5:32:06 PM UTC-4, Ian Lance Taylor wrote: > > On Fri, Oct 6, 2017 at 1:23 PM, XXX ZZZ > > wrote: > > > > So we are making a platform where we have to use a TON of short lived > > structs, in order to optimize this we intend to use sync pool, however > on > > our