mennanov / fieldmask-utils

Protobuf Field Mask Go utils
MIT License
229 stars 26 forks source link

What I set is NOT what I get ??? #36

Closed leeming87v5 closed 9 months ago

leeming87v5 commented 1 year ago
package main

import (
    "fmt"

    msku "github.com/mennanov/fieldmask-utils"
)

func main() {
    var (
        err  error
        mask msku.Mask
    )

    if mask, err = msku.MaskFromPaths(
        []string{"a.b.c"},
        func(s string) string { return s },
    ); err != nil {
        panic(err)
    }

    if _, ok := mask.Get("a.b.c"); ok {
                 // I expected this would work
        fmt.Println("That's Good! As Expcted!")
    } else {
                // but I got this instead.
                // Why ???
        fmt.Println("Oops! Suprise!")
    }
}
rMaxiQp commented 11 months ago

Here is the implementation. Since it's a nested mask, I don't think mask.Get("a.b.c") would work here...

mennanov commented 9 months ago

Here is the implementation. Since it's a nested mask, I don't think mask.Get("a.b.c") would work here...

right, the mask is nested so it works as expected