Download common/copy.go from AZILS/new-api: direct link, hf CLI and curl.
- Browser
- Download file 341 Bytes
-
https://huggingface.co/spaces/AZILS/new-api/resolve/main/common/copy.go
- Command line
-
hf download hf://spaces/AZILS/new-api/common/copy.go
-
curl -L -o copy.go https://huggingface.co/spaces/AZILS/new-api/resolve/main/common/copy.go
341 Bytes
| package common | |
| import ( | |
| "fmt" | |
| "github.com/jinzhu/copier" | |
| ) | |
| func DeepCopy[T any](src *T) (*T, error) { | |
| if src == nil { | |
| return nil, fmt.Errorf("copy source cannot be nil") | |
| } | |
| var dst T | |
| err := copier.CopyWithOption(&dst, src, copier.Option{DeepCopy: true, IgnoreEmpty: true}) | |
| if err != nil { | |
| return nil, err | |
| } | |
| return &dst, nil | |
| } | |