[go-nuts] MongoDB + Golang + Get Shards Count + Get Chunks Count

2018-02-20 Thread kumargv
HI GUYS , if pymongo.version >= "3.2.2": mongos_conn = pymongo.MongoClient(host, port) else: mongos_conn = pymongo.Connection(host, port) chunks_count= mongos_conn.config.chunks.count()#rs.conf() shards_count= mongos_conn.config.shards.count()#rs.conf() sharded

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread jelle
Two more use cases of vendor that I would like to keep: - A single audit trail for all go code going into production binaries in a git log. - A single place to enforce upgrades for multiple binaries in a monorepo. Perhaps a top-level meta-module could do the trick? On Tuesday, February 20, 2018

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Chandru
One shortcoming I see in this proposal compared to dep is the necessity of operating a proxy to achieve reasonable security. Without a proxy or a lock file, a repository take-over as it happened in the case of go-bindata will lead to vgo automatically downloading potentially malicious code. In the

Re: [go-nuts] Re: Golang HTTP POST handling

2018-02-20 Thread Sankar P
Thanks. Will do. 2018-02-21 4:31 GMT+05:30 Andrew Watson : > You should, of course, consider adding some rigor such as CSRF protection > to that form! I'd suggest something like http://www. > gorillatoolkit.org/pkg/csrf for that! > > > On Tuesday, February 20, 2018 at 11:16:57 AM UTC-5, Sankar wr

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Dominik Honnef
Hi, I'd like your input on two concern I have, one as a tool developer and one with regard to reproducible builds. With go and go get, it is expected that code will not compile until all dependencies have been explicitly downloaded. Hence, it is acceptable for tools such as staticcheck to also fa

[go-nuts] Re: The Trouble With Tokens (Refresh Tokens, that is...)

2018-02-20 Thread Andrew Watson
I fixed my problem myself. It turns out the app that consumes the tokens also needs to load the oauth2 config with client id, secret etc. I did not know this! On Tuesday, February 20, 2018 at 4:11:09 PM UTC-5, Andrew Watson wrote: > > So, I built something that uses the 3 step OAuth 2.0 Dance

[go-nuts] Re: strings.Split behavior

2018-02-20 Thread Krzysztof Kowalczyk
Maybe this will help understand what Split() does: https://play.golang.org/p/U7gkrBs8IaZ func main() { s := "this/that there/here that/this" tmp := strings.Split(s, "/") fmt.Printf("%#v\n", tmp) } Output: []string{"this", "that there", "here that", "this"} So when you loop over strings, i

Re: [go-nuts] Re: Go += Package Versioning

2018-02-20 Thread Peter Bourgon
As far as I understand it - github.com/user/foo is expected to house package foo for SemVer 0.x.x – 1.x.x - github.com/user/foo/v2 is expected to house package foo for SemVer 2.x.x - github.com/user/foo/v3 is expected to house package foo for SemVer 3.x.x And so on. Appending the additional path

[go-nuts] Re: Go += Package Versioning

2018-02-20 Thread Brian Slesinsky
I'm wondering how to respond to security patches. After a patch, any go.mod file mentioning an older version of the library is a candidate for version-bumping: download the new version, test, and do a commit with the new version number if all goes well. It's nice that it can be done in any orde

[go-nuts] intelliji can't access go 1.10 std lib on Mac OS

2018-02-20 Thread Joseph Lorenzini
All: I may just need to open a bug with intelliji but I find the behavior so peculiar that I thought i'd ask if anyone who codes go in intelliji may know what's going on. I uninstalled go 1.9.3 and installed go 1.10. After I do that, intelliji can no longer find any packages in the std lib and

[go-nuts] Re: Go += Package Versioning

2018-02-20 Thread Jon Calhoun
Would you be willing to create an example illustrating how a versioned package should look with major version changes? You have great examples for the minor/patch changes, but I don't see any concrete examples for a major version bump. On Tuesday, February 20, 2018 at 12:20:54 PM UTC-5, Russ Co

Re: [go-nuts] json -> struct -> html template

2018-02-20 Thread Alex Dvoretskiy
Thanks, Burak! On Tuesday, February 20, 2018 at 4:29:44 PM UTC-8, Burak Serdar wrote: > > On Tue, Feb 20, 2018 at 5:23 PM, Alex Dvoretskiy > > wrote: > > Hello golang-nuts, > > > > https://play.golang.org/p/Lib9EfWcsjG > > > > If you run this code it works fine. But if you remove one "Actor"

Re: [go-nuts] json -> struct -> html template

2018-02-20 Thread Burak Serdar
On Tue, Feb 20, 2018 at 5:23 PM, Alex Dvoretskiy wrote: > Hello golang-nuts, > > https://play.golang.org/p/Lib9EfWcsjG > > If you run this code it works fine. But if you remove one "Actor" key - > template stops executing: "template: movielist:10:14: executing "movielist" > at <.Actor.Name>: can't

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Wojciech S. Czarnecki
On Tue, 20 Feb 2018 12:20:19 -0500 Russ Cox wrote: > https://research.swtch.com/vgo. > Russ Amazing! The 'minimal version selection' approach is briliant. Where it lacks for me is about keeping up with security patches. If my module keeps libFoo at 1.2.3 it will not see a backported fix that c

[go-nuts] Re: Go += Package Versioning

2018-02-20 Thread s
I'd like to understand the expectations of library maintainers better. I am particularly thinking about the reference to setting major versions through import paths, like github.com/go-yaml/yaml/v2. Is the expectation that library owners would need to change the structure of their project like

[go-nuts] json -> struct -> html template

2018-02-20 Thread Alex Dvoretskiy
Hello golang-nuts, https://play.golang.org/p/Lib9EfWcsjG If you run this code it works fine. But if you remove one "Actor" key - template stops executing: "template: movielist:10:14: executing "movielist" at <.Actor.Name>: can't evaluate field Name in type *main.Actor" Modified version: https:

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Tom Mitchell
On Tue, Feb 20, 2018 at 2:29 PM, Bakul Shah wrote: > On Tue, 20 Feb 2018 13:02:47 -0800 David Anderson > wrote: > > > > As a counterpoint to this: with vgo, I plan to make all my binary modules > > specify that they want the latest versions of everything, > . > > The right choice here is no

[go-nuts] Re: Go 1.10 is released

2018-02-20 Thread Andrew Watson
Awesome! I discovered this by accident because I was upgrading my MBP via homebrew expecting a 1.9.x version and it came up with 1.10! On Friday, February 16, 2018 at 2:36:22 PM UTC-5, Andrew Bonventre wrote: > > Hello gophers, > > We just released Go 1.10. > > You can read the announcement blog

[go-nuts] Re: Golang HTTP POST handling

2018-02-20 Thread Andrew Watson
You should, of course, consider adding some rigor such as CSRF protection to that form! I'd suggest something like http://www.gorillatoolkit.org/pkg/csrf for that! On Tuesday, February 20, 2018 at 11:16:57 AM UTC-5, Sankar wrote: > > Hi, > > I have a Golang HTTP server which is consumed by mobi

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Bakul Shah
On Tue, 20 Feb 2018 13:02:47 -0800 David Anderson wrote: > > As a counterpoint to this: with vgo, I plan to make all my binary modules > specify that they want the latest versions of everything, and update that > pinning every couple of weeks/months. If I encounter bugs, I'll report > them, and m

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Dave MacFarlane
I really like this, except for the claim that it the blog post that it will eliminate vendoring and deprecate GOPATH and the problems that will cause for backwards compatibility for things that are currently using them. If this is going to result in removing language features (ie. vendoring), shoul

Re: [go-nuts] Re: Dero: CryptoNote protocol + smart contracts using golang

2018-02-20 Thread 867cryptocurrency
Hello Dave, I would like to thank you for your contribution to protecting the open source communities that you are a part of. I would also like to take a moment to touch on the points you made. The license is not currently open source, however, we felt that from a discussion and research POV th

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread David Anderson
I think we're agreeing, with different words (but please correct me if I'm wrong!). Yes, active maintenance is required with vgo, as demonstrated in the tour. But crucially, I do not get held back by library writers that don't update, I'm only held back by my own laziness in failing to update at t

Re: [go-nuts] strings.Split behavior

2018-02-20 Thread bucarr
Thank you, Marvin. About the same time you wrote this, the answer likewise dawned on me. > Look at https://play.golang.org/p/2tz2asuZcGc where I have changed > > fmt.Println(tmp) > to > fmt.Printf("%#v\n", tmp) > > and I think you will understand that tmp does not contain what yo

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Devon H. O'Dell
2018-02-20 13:02 GMT-08:00 David Anderson : > [snip] > > I also believe the tooling around vgo should encourage/make default this > behavior for binary modules (and maybe for library modules as well, though > that's less clear to me). The default behavior when writing Go programs > should be to use

Re: [go-nuts] strings.Split behavior

2018-02-20 Thread bucarr
On Tuesday, February 20, 2018 at 2:00:32 PM UTC-7, Jan Mercl wrote: > > > I don't know how the concept of word got involved in the "expected" > behavior, but the code shown has nothing to do with something like "word". > It works purely with strings and slices of strings and is AFAICT working a

[go-nuts] The Trouble With Tokens (Refresh Tokens, that is...)

2018-02-20 Thread Andrew Watson
So, I built something that uses the 3 step OAuth 2.0 Dance to get access to gmail. It stores the OAuth tokens after encrypting them with Vault transit keys and then I built something that decrypts those tokens, constructs an OAuth 2.0 client using them and goes looking for things in my inbox.

Re: [go-nuts] strings.Split behavior

2018-02-20 Thread Marvin Renich
* buc...@gmail.com [180220 15:51]: > package main > > import ( > "fmt" > "strings" > ) > > func main() { > s := "this/that there/here that/this" > tmp := strings.Split(s, "/") > fmt.Println(tmp) > for _, s1 := range tmp { > if strings.Contains(s1, "that") { > fmt.Println(s1

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Bakul Shah
On Tue, 20 Feb 2018 15:51:39 -0500 Russ Cox wrote: > > On Tue, Feb 20, 2018 at 3:46 PM, Bakul Shah wrote: > > > May be one can write a tool around or similar to "vgo test" to > > test and update not to the latest but some earlier version. > > For example, if pkg A currently imports C v1.x and B

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread David Anderson
On Tue, Feb 20, 2018 at 11:37 AM, Russ Cox wrote: > On Tue, Feb 20, 2018 at 1:55 PM, David Anderson wrote: > >> I love this. I want it now. >> > > go get -u golang.org/x/vgo :-) > > I've struggled with `glide` and `dep` dependency hell a lot in my Go >> projects (especially those that use the Ku

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread David Anderson
On Tue, Feb 20, 2018 at 12:46 PM, Bakul Shah wrote: > On Tue, 20 Feb 2018 11:55:00 -0800 "Devon H. O'Dell" < > devon.od...@gmail.com> wrote: > Devon H. O'Dell writes: > > 2018-02-20 11:39 GMT-08:00 Russ Cox : > > > On Tue, Feb 20, 2018 at 2:35 PM, Devon H. O'Dell < > devon.od...@gmail.com> > > >

Re: [go-nuts] strings.Split behavior

2018-02-20 Thread Jan Mercl
On Tue, Feb 20, 2018 at 9:51 PM wrote: > But instead the second fmt.Println() output implies that it grabbed more than one word. > > I'm a noob and puzzled by this behavior. I don't know how the concept of word got involved in the "expected" behavior, but the code shown has nothing to do with so

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Russ Cox
On Tue, Feb 20, 2018 at 3:46 PM, Bakul Shah wrote: > May be one can write a tool around or similar to "vgo test" to > test and update not to the latest but some earlier version. > For example, if pkg A currently imports C v1.x and B imports C > v1.y, through iterative testing one may find C v1.z

[go-nuts] strings.Split behavior

2018-02-20 Thread bucarr
package main import ( "fmt" "strings" ) func main() } s := "this/that there/here that/this" tmp := strings.Split(s, "/") fmt.Println(tmp) for _, s1 := range tmp { if strings.Contains(s1, "that") { fmt.Println(s1) } } } Output: this was as expected: [this that there here that this]

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Bakul Shah
On Tue, 20 Feb 2018 11:55:00 -0800 "Devon H. O'Dell" wrote: Devon H. O'Dell writes: > 2018-02-20 11:39 GMT-08:00 Russ Cox : > > On Tue, Feb 20, 2018 at 2:35 PM, Devon H. O'Dell > > wrote: > >> > >> With regards to minimum version selection, if I depend on some feature > >> present, this comes wi

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Devon H. O'Dell
2018-02-20 11:39 GMT-08:00 Russ Cox : > On Tue, Feb 20, 2018 at 2:35 PM, Devon H. O'Dell > wrote: >> >> With regards to minimum version selection, if I depend on some feature >> present, this comes with two implicit dependencies: correctness and >> safety. My knee-jerk reaction here is that the ti

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Russ Cox
On Tue, Feb 20, 2018 at 2:35 PM, Devon H. O'Dell wrote: > With regards to minimum version selection, if I depend on some feature > present, this comes with two implicit dependencies: correctness and > safety. My knee-jerk reaction here is that the time folks spend > "telling the package manager,

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Russ Cox
On Tue, Feb 20, 2018 at 1:55 PM, David Anderson wrote: > I love this. I want it now. > go get -u golang.org/x/vgo :-) I've struggled with `glide` and `dep` dependency hell a lot in my Go > projects (especially those that use the Kubernetes client library, which > abuses "I, the library author,

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread Devon H. O'Dell
With regards to minimum version selection, if I depend on some feature present, this comes with two implicit dependencies: correctness and safety. My knee-jerk reaction here is that the time folks spend "telling the package manager, 'no, use at least Y,'" will largely be in response to these sorts

Re: [go-nuts] Re: Go += Package Versioning

2018-02-20 Thread Russ Cox
On Tue, Feb 20, 2018 at 1:17 PM, Zellyn wrote: > A couple of initial questions: > >- The "pretend you're importing github.com/foo/bar but actually pull >it from localgit.host/foo/bar" functionality of dep was going to really >simplify things for us. I can't quite tell whether vgo incl

Re: [go-nuts] Go += Package Versioning

2018-02-20 Thread David Anderson
I love this. I want it now. I've struggled with `glide` and `dep` dependency hell a lot in my Go projects (especially those that use the Kubernetes client library, which abuses "I, the library author, can define byzantine constraints on my users" to the extreme). The way I've described it informal

Re: [go-nuts] Loosing type after json.Unmarshal

2018-02-20 Thread Burak Serdar
On Tue, Feb 20, 2018 at 9:25 AM, wrote: > Hi, > > please have a look at this code why do I loose type information after > json.Unmarshal? structA is an interface{}. Before unmarshal, it is pointing to a StructA value. Unmarshal, seeing that the argument is an interface{}, unmarshals the JSON i

[go-nuts] Loosing type after json.Unmarshal

2018-02-20 Thread marian . sokolowski
Hi, please have a look at this code why do I loose type information after json.Unmarshal? -- 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,

[go-nuts] Re: Go += Package Versioning

2018-02-20 Thread Zellyn
A couple of initial questions: - The "pretend you're importing github.com/foo/bar but actually pull it from localgit.host/foo/bar" functionality of dep was going to really simplify things for us. I can't quite tell whether vgo includes that functionality or not. We would want to do

[go-nuts] Go += Package Versioning

2018-02-20 Thread Russ Cox
Hi everyone, I have a new blog post you might be interested in. https://research.swtch.com/vgo. I'll try to watch this thread to answer any questions. Best, Russ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group an

Re: [go-nuts] Re: Golang HTTP POST handling

2018-02-20 Thread Sankar P
Perfect. Thanks. This is what I wanted. I just replaced id with name and it started working. 2018-02-20 21:59 GMT+05:30 : > This worked for me in a project. My form is > and the input is . On the server I > use r.ParseForm then r.FormValue("password"). > > Matt > > On Tuesday, February 20, 2018

[go-nuts] Re: Golang HTTP POST handling

2018-02-20 Thread matthewjuran
This worked for me in a project. My form is and the input is . On the server I use r.ParseForm then r.FormValue("password"). Matt On Tuesday, February 20, 2018 at 10:16:57 AM UTC-6, Sankar wrote: > > Hi, > > I have a Golang HTTP server which is consumed by mobile Apps via HTTP. > > For one wo

[go-nuts] Re: Golang HTTP POST handling

2018-02-20 Thread matthewjuran
This worked for me. My form is " > Password > > Repeat Password > required> > Change Password > > > > ` > res.WriteHeader(http.StatusOK) > res.Header().Set("Content-Type", "text/html") > res.Write([]byte(body)) > } else if req.Method == http.MethodPost { > err := req.ParseForm() > log.Println(

[go-nuts] Golang HTTP POST handling

2018-02-20 Thread Sankar
Hi, I have a Golang HTTP server which is consumed by mobile Apps via HTTP. For one workflow (reset-password) alone, I needed a web interface. So instead of creating a new different webapp, I decided to make an endpoint emit text/html instead of JSON and then serve a static HTML page, which wi

[go-nuts] Re: Tweaking sync.Pool for mostly-empty pools

2018-02-20 Thread Aliaksandr Valialkin
Just FYI, there is currently the following activity regarding sync.Pool optimizations that may land to go1.11: - Increasing per-P pool capacity, which should reduce lock contention on shared items. https://go-review.googlesource.com/c/go/+/49110 . - Avoiding pool resets during GC - https://gith

Re: [go-nuts] go fmt and CI (e.g. gitlab)

2018-02-20 Thread Jérôme LAFORGE
Thx, it is perfect. Le lundi 19 février 2018 20:35:48 UTC+1, Stéphane Jeandeaux a écrit : > > > Hi Jerome, > > You can take a look at git hooks https://golang.org/misc/git/pre-commit. > > Code: > test -z "$(gofmt -s -l $(find . -name '*.go' -type f -print) | tee > /dev/stderr)" > > Thanks and reg

[go-nuts] Re: All Forms of Wishful Generics

2018-02-20 Thread matthewjuran
> > This seems deeply insightful to me. Thanks Michael. It's not just maps, slices, append, and make. Every single operator could > be considered too to be "generic" because each operates on an indefinite > number of types. > But Go gains much from the special-case syntax and semantics ass

[go-nuts] Re: All Forms of Wishful Generics

2018-02-20 Thread Egon
On Monday, 19 February 2018 12:06:09 UTC+2, RickyS wrote: > > Back when I first learned about the diamond problem with multiple > inheritance, I've known we need someone to invent the next and better thing > after inheritance. I do hope somebody smarter than me is somewhere trying. > Or even has

Re: [go-nuts] Re: All Forms of Wishful Generics

2018-02-20 Thread Mandolyte
+1 On Monday, February 19, 2018 at 12:37:14 PM UTC-5, Michael Jones wrote: > > Matthew Juran wrote: *"...but if you use maps, slices, append, make, you > are already using generics."* > > This seems deeply insightful to me. Perhaps a better question than the > self-defeatingly open question of "

Re: [go-nuts] json encoding & decoding interface types

2018-02-20 Thread Burak Serdar
On Mon, Feb 19, 2018 at 5:14 PM, Doğan Kurt wrote: > Hi Burak, > > The example objects are very simplified. In real code, there are many more > object types and some of them looks exactly same. For instance; > > type chromeHomepage struct { > Url string > File string > } > > type firefoxHomepage

Re: [go-nuts] Re: Dero: CryptoNote protocol + smart contracts using golang

2018-02-20 Thread David Anderson
Specifically, for folks reading this thread: I'm pretty sure the license on this code is not open source, by any definition of the term (severe restrictions on allowed uses, also does not specify that the grant is perpetual - so afaict it could be revoked retroactively at any time). If such things

[go-nuts] Reliably test for connection establishment error

2018-02-20 Thread Marco Jantke
I need to do retries for HTTP requests when the connection can't be established initially. As soon as there was a successful connection no retry should happen anymore. While there is error as return from the http.RoundTripper I'm not sure how I can accomplish to find out whether a connection wa

Re: [go-nuts] Re: All Forms of Wishful Generics

2018-02-20 Thread Jesper Louis Andersen
On Mon, Feb 19, 2018 at 9:29 PM Rob Pike wrote: > Jesper, > > I find myself in rare but mild disagreement about your claims for > stack-based virtual machines. Please have a look at this short paper about > the Dis VM from Inferno: http://flint.cs.yale.edu/jvmsem/doc/inferno.ps > > There is a cha

[go-nuts] Re: import paths - slash vs backslash

2018-02-20 Thread Volker Dobler
On Friday, 10 November 2017 19:31:37 UTC+1, Tim Hockin wrote: > > Is it valid to say `import "github.com\foo\bar" (windows path > separators) or must it be "github.com/foo/bar"? I couldn't find a > canonical answer to this. > Using backslashes as a path separator is wrong on Windows too. Just