[go-nuts] Re: The next layer of abstraction for Go development?

2020-06-14 Thread Saied Seghatoleslami
As evidence for not needing the next layer of abstraction, I offer Django class-based-views. The go approach is much more understandable and easier to follow. On Saturday, June 13, 2020 at 4:11:59 PM UTC-4, Asim Aslam wrote: > > Might not be the right place for this discussion but also useful t

[go-nuts] Re: First column in sql rows.Scan is always zero

2020-06-10 Thread Saied Seghatoleslami
(bool) type assertion failed") } p.Active = *xActive case Online: xOnline, ok := g[i].(*bool) if !ok { return fmt.Errorf("Online (bool) type assertion failed") } p.Online = *xOnline } } return nil } On Monday, June 8, 2020 at 7:03:14 PM UTC-4, Saied Seghatoleslami wrote: > > I am s

[go-nuts] First column in sql rows.Scan is always zero

2020-06-08 Thread Saied Seghatoleslami
I am scanning database tables into a structure explicitly (with &struct.field) that works just fine (working path below). But my tables have different columns, so I am working to generalize the API. There are two methods that build and reverse a []interface{} to be supplied to scan. I have

[go-nuts] Re: x, err = some_func(); if err != nil { } seems awkward

2020-06-04 Thread Saied Seghatoleslami
There is also the idea that an error is not necessarily an error in the sense that it is wrong but it is something that prevents the operation. It could be that the far end is out of service or the network connection is down or the port is closed or the file permissions are set to what is not

[go-nuts] Re: Im battling to understand pointers to strings in a function - Please help

2020-05-30 Thread Saied Seghatoleslami
1. Check what is *string[1000]. Maybe you mean *[1000]string 2. Also, it looks like you are passing [1000][2]string etc. to idx, they are of different types. Once you fix that, below are the errors that you get 3. Finally, why use fixed size arrays, that is into idiomatic go. Using slices is.

[go-nuts] Re: How to parseFile with ...string?

2020-05-20 Thread Saied Seghatoleslami
This is what Alex Edwards in his book "Let's Go" does and I am using it. He writes it to a buffer and checks for errors. Enter code here... Enter code here...func (app *App) render(w http.ResponseWriter, r *http. Request, name string) { t := app.cache[name] buf := new(bytes.Buffer) tData, err :

[go-nuts] Re: golang protobuf, struct copy problem

2020-05-20 Thread Saied Seghatoleslami
Why not use gob encoding? I am using it across nats and it is working fine. The only workaround that I have had to do is to string encode the errors and convert them back to errors on the other side. On Friday, May 8, 2020 at 2:56:22 PM UTC-4, cheng dong wrote: > > i use protobuf to do rpc in

[go-nuts] Re: Variadic Arguments and Interfaces

2020-05-17 Thread Saied Seghatoleslami
I found this article by Nick Gauthier from 2016. https://www.meetspaceapp.com/2016/05/23/writing-a-data-mapper-in-go-without-an-orm.html. The original idea is contributed to Martin Fowler. Someone else has solved this problem before. On Friday, September 7, 2012 at 4:45:07 PM UTC-4, Paddy

Re: [go-nuts] Re: Variadic Arguments and Interfaces

2020-05-17 Thread Saied Seghatoleslami
, exchData.Role > instead of just a interface slice > > On 17/05/2020 23:27, Saied Seghatoleslami wrote: > > I hate to dig up something from 2012, but I have come across a similar > issue where I can use an explanation. The signature of the Query function > in the sql

[go-nuts] Re: Variadic Arguments and Interfaces

2020-05-17 Thread Saied Seghatoleslami
I hate to dig up something from 2012, but I have come across a similar issue where I can use an explanation. The signature of the Query function in the sql package is: func (db *DB ) Query(query string , args ...i

[go-nuts] Re: Unmarshal XML element to interface{}

2020-05-14 Thread Saied Seghatoleslami
I have tried unmarshalling various JSON and XML files with limited success. So I ended up writing a "lexer" along the lines of Rob Pike's lecture in Australia. I have had good success with it in a bunch of projects. I would be very interested to get some comments on what the community thinks

[go-nuts] Re: suspect or: role != admin || role != superadmin

2020-05-11 Thread Saied Seghatoleslami
Thank you, guys. I walked myself into a logical trap. Professor Isapovich is probably turning in his grave and giving me an F in some heavenly grade book. On Monday, May 11, 2020 at 2:53:02 PM UTC-4, Saied Seghatoleslami wrote: > > I have seen a ticket on this topic (or something rela

[go-nuts] suspect or: role != admin || role != superadmin

2020-05-11 Thread Saied Seghatoleslami
I have seen a ticket on this topic (or something related to it) on Github but I thought I would ask this community first: In first instance, I got "suspect or: role != admin || role != superadmin" In the second instance, it works just fine. I have verified that role is string type (with %T verb

[go-nuts] Re: Why I fear Go

2020-05-09 Thread Saied Seghatoleslami
You should go for it. If you think you can, or you think you can't, in both cases you are right. On Saturday, May 9, 2020 at 1:57:23 PM UTC-4, shammah Zealsham Agwor wrote: > > I have been programming since 2016 but I have never really dived deep into > any language and haven't got a job with a

Re: [go-nuts] A modest format suggestion

2020-04-24 Thread Saied Seghatoleslami
Doesn't this style of writing assume that there are a lot of arguments to be passed to function which I think is not a good practice since it makes it much harder to remember what the function does and how to call and most importantly, how to debug it when becomes necessary? So, if there are a lot