go-masker icon indicating copy to clipboard operation
go-masker copied to clipboard

How do i get an unmasked value from the struct?

Open roborobs1023 opened this issue 3 years ago • 1 comments

say for instance I have

package main

import ( masker "github.com/ggwhite/go-masker" )

func main() { masker.String(masker.MName, "ggwhite") masker.String(masker.MID, "A123456789") masker.String(masker.MMobile, "0987987987") }

how would I be able to unmask the strings for use in sql query statement?

roborobs1023 avatar Aug 18 '20 14:08 roborobs1023

@roborobs1023 I think it is not the responsibility of this package to unmask the value after masked. Why? Because when you want to mask value, you actually already know the exact value or unmasked value before you mask it. Hence, if you want to get an unmasked value, just use an old variable. For example:

var name = "customer name"
var maskedName = masker.String(masker.MName,  name)

fmt.Println(name) // print "customer name"
fmt.Println(maskedName) // print masked customer name

yusufsyaifudin avatar Jun 22 '21 08:06 yusufsyaifudin