MCPcopy
hub / github.com/gofiber/fiber / AcquireFile

Function AcquireFile

client/request.go:1037–1054  ·  view source on GitHub ↗

AcquireFile returns a (pooled) File object and applies the provided SetFileFunc functions to it.

(setter ...SetFileFunc)

Source from the content-addressed store, hash-verified

1035
1036// AcquireFile returns a (pooled) File object and applies the provided SetFileFunc functions to it.
1037func AcquireFile(setter ...SetFileFunc) *File {
1038 fv := filePool.Get()
1039 if fv != nil {
1040 f, ok := fv.(*File)
1041 if !ok {
1042 panic(errFileTypeAssertion)
1043 }
1044 for _, v := range setter {
1045 v(f)
1046 }
1047 return f
1048 }
1049 f := &File{}
1050 for _, v := range setter {
1051 v(f)
1052 }
1053 return f
1054}
1055
1056// ReleaseFile returns the File object to the pool.
1057// Do not use the released File afterward to avoid data races.

Callers 8

Test_Parser_Request_BodyFunction · 0.85
newBenchmarkRequestFunction · 0.85
AddFileMethod · 0.85
AddFileWithReaderMethod · 0.85
Test_Request_FileFunction · 0.85
Test_Request_FilesFunction · 0.85
Benchmark_Request_FilesFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by 6

Test_Parser_Request_BodyFunction · 0.68
newBenchmarkRequestFunction · 0.68
Test_Request_FileFunction · 0.68
Test_Request_FilesFunction · 0.68
Benchmark_Request_FilesFunction · 0.68