[go-nuts] Re: Need some help on my basic "Backup size" calculator

2017-06-04 Thread Egon
See filepath.Walk (https://golang.org/pkg/path/filepath/#Walk) If you wish to recurse with ioutil.ReadDir or File.Readdir (https://golang.org/pkg/os/#File.Readdir), you have to do it manually. Nested structs -- it depends what you are doing. I would simplify it to: type Stat struct { FileCount

Re: [go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-06-04 Thread Florin Pățan
Feel free to report me to the CoC committee if you think that telling someone point blank they are wasting their time and creating noise without having a well defined problem or solution. And yes, I'm one of those "zealots" who can actually read and know that this programming language is called Go

[go-nuts] Need some help on my basic "Backup size" calculator

2017-06-04 Thread gioflux
Hi there, I'm very new to Golang, and quite honestly haven't coded in a long time so bear with me if this is an very basic question. I'm trying to build a basic backup program, which will take a path (string) and then calculate the total "backup size" of the entire backup (and all the child fo

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-06-04 Thread Egon
On Monday, 5 June 2017 06:59:46 UTC+3, utyug...@mail.com wrote: > > > > On Sunday, June 4, 2017 at 12:25:17 PM UTC-4, Egon wrote: >> >> I think you are missing the point of my comment. >> >> I'm all for generics, but I also can survive without them without much of >> a problem. (I'm even maintai

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-06-04 Thread utyughjgut
Why such a vicious attack? This type of behavior against those exploring generics in golang(i call Go this to spite the zealots) is a scourge gone uncheck for too long. No need for comments to be speckled with demeaning overtone. On Friday, June 2, 2017 at 4:17:54 AM UTC-4, Florin Pățan wrote:

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-06-04 Thread utyughjgut
On Sunday, June 4, 2017 at 12:25:17 PM UTC-4, Egon wrote: > > I think you are missing the point of my comment. > > I'm all for generics, but I also can survive without them without much of > a problem. (I'm even maintaining > https://docs.google.com/document/d/1vrAy9gMpMoS3uaVphB32uVXX4pi-HnNjk

[go-nuts] Re: "cannot allocate memory" problem

2017-06-04 Thread Dmitry Mishin
I figured it. My exec.Command's were leaving a bunch of zombie processes. Had to do cmd.Wait() on them to exit cleanly. On Thursday, June 1, 2017 at 9:25:51 PM UTC-7, Dmitry Mishin wrote: > > I have the same impression... > > Added a 300 msec sleep before each folder read task. Will see how it go

Re: [go-nuts] gob's interpreted machine

2017-06-04 Thread Ian Lance Taylor
On Sat, Jun 3, 2017 at 9:10 AM, Santhosh Ram Manohar wrote: > From https://blog.golang.org/gobs-of-data > > "The first time you encode a value of a given type, the gob package builds a > little interpreted machine specific to that data type. It uses reflection on > the type to construct that machi

[go-nuts] Re: CORS error when using Gorilla Mux

2017-06-04 Thread Oren
update: to only allow ajax requests from my domains I modify the code: w.Header().Set("Access-Control-Allow-Origin", "https://foo.my-domain.com";) w.Header().Set("Access-Control-Allow-Origin", "https://bar.my-domain.com";) w.Header().Set("Access-Control-Allow-Origin", "http://localhost:8080) O

[go-nuts] Re: How to compare two network addresses (stringifyed or not) for equality?

2017-06-04 Thread 'Константин Иванов' via golang-nuts
Ah, hell. Sorry, sorry, sorry. "[::]" is just ipv6 version of "0.0.0.0". Okay. Hah, and I can to use "[::0:0:1]:9090" or "[::0:1]:9090" or "[::1]:9090" and it will work. Hah, thank you man! Thank for you time. воскресенье, 4 июня 2017 г., 18:32:42 UTC+3 пользователь Silviu Capota Mera написал:

[go-nuts] Re: CORS error when using Gorilla Mux

2017-06-04 Thread Oren
I solved with the following: package main import ( "log" "net/http" "github.com/gorilla/mux" ) func corsMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { log.Println("Executing middleware", r.Method) if r.Method == "OP

[go-nuts] Re: Newbie How to read unmarshall a varient struct in Json

2017-06-04 Thread Amnon Baron Cohen
Thanks for bringing the article to my attention. The final section "*Encoding and decoding generics*" was exactly what I was looking for. On Sunday, 4 June 2017 12:53:42 UTC+1, Jon Calhoun wrote: > > See the last section of this article where it talks about generics - > https://blog.gopheracade

Re: [go-nuts] CGO & Plugins

2017-06-04 Thread Ian Lance Taylor
On Sun, Jun 4, 2017 at 3:01 AM, dc0d wrote: > > Some clarifications on future of plugins would be nice though. To be honest I thought plugins would have fewer problems than they would up having. And in any case the API seems fine, so any reworking can preserve the API. I think the future of plu

[go-nuts] Re: Golang, SQL and ORM avoidance techniques

2017-06-04 Thread 'Niko Schwarz' via golang-nuts
There's no great trick, but there are some general ideas you should be aware of. - Active Record Pattern - Database normalization - The Google way of storing data: Cloud Spanner

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-06-04 Thread Egon
I think you are missing the point of my comment. I'm all for generics, but I also can survive without them without much of a problem. (I'm even maintaining https://docs.google.com/document/d/1vrAy9gMpMoS3uaVphB32uVXX4pi-HnNjkMEgyAHX4N4 to understand the problem better) The issue I was trying

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-06-04 Thread mhhcbon
given the fact that actually everybody disagrees on that idea, or even something similar according to some feedback. I want to put the question differently. My mean is to say that golang is a basis to build upon in general that is better than other existing solutions. imho, golang is governed

[go-nuts] Re: How to compare two network addresses (stringifyed or not) for equality?

2017-06-04 Thread silviucapota
Hi I think you wanted return ahost == bhost (instead of aport == bport) inside the addrCmp function, right ? Because the client is always assigned a random port for a TCP connection And of course, you will have to compare at nc (net.Conn) level, not at listener level, especially when listenin

[go-nuts] CORS error when using Gorilla Mux

2017-06-04 Thread Oren
Any ideas why I get '403: forbidden' when making CORS request to my web service? https://github.com/oren/doc-api/blob/dc332507e3a9c5f36a2de6430ec6bf811ffcbd4e/cmd/web/server.go#L90 I am using gorilla mux: ``` corsObj := handlers.AllowedOrigins([]string{"*"}) log.Fatal(http.ListenAndServe(":3000"

[go-nuts] Newbie How to read unmarshall a varient struct in Json

2017-06-04 Thread Jon Calhoun
See the last section of this article where it talks about generics - https://blog.gopheracademy.com/advent-2016/advanced-encoding-decoding/ It isn't exactly what you are doing but the same idea should work in your use case. The encoding/decoding code becomes longer but it makes using the data s

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-06-04 Thread mhhcbon
I feel much better with this, than its counter part, but what s the point, this is so much about a personal opinion. func (p PackageInfo) DeepEmbeddeds(structName string) (ret StringSlice) { strut := p.GetStruct(structName) if strut.GetName() == structName { e := strut.Embeddeds()

Re: [go-nuts] Re: How to parallelize text/template long running functions?

2017-06-04 Thread Simon Ritchie
I was puzzled by something you said earlier: > The template is the only entity that knows exactly which data from the data set is needed. You've just given a bit more information, but I still don't quite understand. You have some C code that you don't control and it's producing some informati

Re: [go-nuts] CGO & Plugins

2017-06-04 Thread dc0d
Thanks for the post! I don't think those caveats could be a setback. Some clarifications on future of plugins would be nice though. On Saturday, June 3, 2017 at 6:32:22 PM UTC+4:30, Nick Groenen wrote: > > On 2017-06-02 19:24:40, Michael Brown wrote: > >Do you have any references on the stabili