NewFile 创建文件
(source string)
| 278 | |
| 279 | // NewFile 创建文件 |
| 280 | func NewFile(source string) (*File, error) { |
| 281 | file := &File{} |
| 282 | |
| 283 | if strings.HasPrefix(source, "http://") || strings.HasPrefix(source, "https://") { |
| 284 | file.URL = source |
| 285 | } else { |
| 286 | return NewFileFromPath(source) |
| 287 | } |
| 288 | |
| 289 | return file, nil |
| 290 | } |
| 291 | |
| 292 | // NewFileFromPath 从路径创建文件 |
| 293 | func NewFileFromPath(path string) (*File, error) { |
nothing calls this directly
no test coverage detected