File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ You have to call it´s GetSecret() method to get the actual value.
55
66It is highly inspired by Pydantic´s SecretStr (https://docs.pydantic.dev/usage/types/#secret-types )
77
8+ Example usage:
89``` go
910package main
1011
@@ -14,20 +15,43 @@ import (
1415)
1516
1617func main () {
17- s := secretstring.SecretString (" this_is_a_secret" )
18- // or
19- // var s SecretString = "this_is_a_secret"
18+ // create a new secret string with default options
19+ s := secretstring.New (" this_is_a_secret" )
2020
2121 fmt.Println (s)
2222 fmt.Println (s.GetSecret ())
23+
24+ // output:
25+ // **********
26+ // this_is_a_secret
2327}
2428```
2529
26- this should output :
30+ Or with custom options :
2731
28- ```
29- ********
30- this_is_a_secret
32+ ``` go
33+ package main
34+
35+ import (
36+ " fmt"
37+ " github.com/chmller/secretstring"
38+ )
39+
40+ func main () {
41+ // create a new secret string with custom options
42+ o := secretstring.Options {
43+ MarshallMasked: false ,
44+ Mask: " ???" ,
45+ }
46+ s := secretstring.NewWithOptions (" this_is_a_secret" , o)
47+
48+ fmt.Println (s)
49+ fmt.Println (s.GetSecret ())
50+
51+ // output:
52+ // ???
53+ // this_is_a_secret
54+ }
3155```
3256
3357It has build in marshaller and unmarshaller for JSON.
You can’t perform that action at this time.
0 commit comments