MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / generateStruct

Function generateStruct

module/application-authorization/auth-driver/auth.go:63–88  ·  view source on GitHub ↗
(cfg interface{})

Source from the content-addressed store, hash-verified

61}
62
63func generateStruct[T any](cfg interface{}) (*T, error) {
64 result := new(T)
65 switch c := cfg.(type) {
66 case string:
67 err := json.Unmarshal([]byte(c), result)
68 if err != nil {
69 return nil, err
70 }
71 case []byte:
72 err := json.Unmarshal(c, result)
73 if err != nil {
74 return nil, err
75 }
76 case *map[string]interface{}, map[string]interface{}:
77 data, err := json.Marshal(c)
78 if err != nil {
79 return nil, err
80 }
81 err = json.Unmarshal(data, result)
82 if err != nil {
83 return nil, err
84 }
85 }
86
87 return result, nil
88}

Callers

nothing calls this directly

Calls 1

MarshalMethod · 0.80

Tested by

no test coverage detected