Re: [go-nuts] How to fix an awful marshal reflection hack

2022-12-01 Thread burak serdar
On Thu, Dec 1, 2022 at 6:39 AM 'Mark' via golang-nuts < golang-nuts@googlegroups.com> wrote: > The reason there's no nullable in the real code is that it isn't needed > there: if the field is to a pointer variable (e.g., *string), then I call > hack() and that adds the '?' to the string so no

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-12-01 Thread 'Mark' via golang-nuts
The reason there's no nullable in the real code is that it isn't needed there: if the field is to a pointer variable (e.g., *string), then I call hack() and that adds the '?' to the string so no need for a nullable bool; otherwise for non-pointers it falls through to the normal processing. So

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-12-01 Thread Marvin Renich
* 'Mark' via golang-nuts [221201 05:17]: > I tried that and it works in the playground, and I added more types and it > still works in the playground . > But in my program it still doesn't work:-( > The actual code is here tdb-go

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-12-01 Thread 'Mark' via golang-nuts
I tried that and it works in the playground, and I added more types and it still works in the playground . But in my program it still doesn't work:-( The actual code is here tdb-go in the file marshal.go from line

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-12-01 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-12-01 at 00:33 -0800, 'Mark' via golang-nuts wrote: > Thanks. I've now tried that as follows: > >         fmt.Printf("@@: %T %v\n", field, field) >         kind = field.Type().Elem().Kind() >         fmt.Printf("##: %T %v\n", field, field) > > In every case the output for kind

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-12-01 Thread 'Mark' via golang-nuts
Thanks. I've now tried that as follows: fmt.Printf("@@: %T %v\n", field, field) kind = field.Type().Elem().Kind() fmt.Printf("##: %T %v\n", field, field) In every case the output for kind before and after was identical. (Naturally, I tried without the print

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-11-30 Thread burak serdar
On Wed, Nov 30, 2022 at 10:17 AM 'Mark' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Yes, I'd already tried that (that's what I started with) and unfortunately > it doesn't work. > It fails if field.Elem() is nil. Try this: kind = field.Type().Elem().Kind() > > On Wednesday,

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-11-30 Thread 'Mark' via golang-nuts
Yes, I'd already tried that (that's what I started with) and unfortunately it doesn't work. On Wednesday, November 30, 2022 at 3:37:47 PM UTC bse...@computer.org wrote: > On Wed, Nov 30, 2022 at 5:29 AM 'Mark' via golang-nuts < > golan...@googlegroups.com> wrote: > >> I have this code which

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-11-30 Thread burak serdar
On Wed, Nov 30, 2022 at 5:29 AM 'Mark' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I have this code which works but has a horrible hack: > ... > nullable := false > kind := field.Kind() // field's type is reflect.Value > if kind == reflect.Ptr { > This should work: kind =

[go-nuts] How to fix an awful marshal reflection hack

2022-11-30 Thread 'Mark' via golang-nuts
I have this code which works but has a horrible hack: ... nullable := false kind := field.Kind() // field's type is reflect.Value if kind == reflect.Ptr { // FIXME How can I improve upon this truly awful hack? switch field.Type().String() { case "*int", "*int8", "*uint8", "*int16",