Skip to content

Commit 6669ec4

Browse files
authored
📝 docs: gofmt & add missing copyright texts (#2013)
1 parent e8a2ba3 commit 6669ec4

29 files changed

+144
-128
lines changed

app.go

+32-27
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,18 @@ type Storage interface {
6363

6464
// ErrorHandler defines a function that will process all errors
6565
// returned from any handlers in the stack
66-
// cfg := fiber.Config{}
67-
// cfg.ErrorHandler = func(c *Ctx, err error) error {
68-
// code := StatusInternalServerError
69-
// var e *fiber.Error
70-
// if errors.As(err, &e) {
71-
// code = e.Code
72-
// }
73-
// c.Set(HeaderContentType, MIMETextPlainCharsetUTF8)
74-
// return c.Status(code).SendString(err.Error())
75-
// }
76-
// app := fiber.New(cfg)
66+
//
67+
// cfg := fiber.Config{}
68+
// cfg.ErrorHandler = func(c *Ctx, err error) error {
69+
// code := StatusInternalServerError
70+
// var e *fiber.Error
71+
// if errors.As(err, &e) {
72+
// code = e.Code
73+
// }
74+
// c.Set(HeaderContentType, MIMETextPlainCharsetUTF8)
75+
// return c.Status(code).SendString(err.Error())
76+
// }
77+
// app := fiber.New(cfg)
7778
type ErrorHandler = func(*Ctx, error) error
7879

7980
// Error represents an error that occurred while handling a request.
@@ -438,12 +439,15 @@ var DefaultErrorHandler = func(c *Ctx, err error) error {
438439
}
439440

440441
// New creates a new Fiber named instance.
441-
// app := fiber.New()
442+
//
443+
// app := fiber.New()
444+
//
442445
// You can pass optional configuration options by passing a Config struct:
443-
// app := fiber.New(fiber.Config{
444-
// Prefork: true,
445-
// ServerHeader: "Fiber",
446-
// })
446+
//
447+
// app := fiber.New(fiber.Config{
448+
// Prefork: true,
449+
// ServerHeader: "Fiber",
450+
// })
447451
func New(config ...Config) *App {
448452
// Create a new app
449453
app := &App{
@@ -609,15 +613,15 @@ func (app *App) GetRoute(name string) Route {
609613
// Use registers a middleware route that will match requests
610614
// with the provided prefix (which is optional and defaults to "/").
611615
//
612-
// app.Use(func(c *fiber.Ctx) error {
613-
// return c.Next()
614-
// })
615-
// app.Use("/api", func(c *fiber.Ctx) error {
616-
// return c.Next()
617-
// })
618-
// app.Use("/api", handler, func(c *fiber.Ctx) error {
619-
// return c.Next()
620-
// })
616+
// app.Use(func(c *fiber.Ctx) error {
617+
// return c.Next()
618+
// })
619+
// app.Use("/api", func(c *fiber.Ctx) error {
620+
// return c.Next()
621+
// })
622+
// app.Use("/api", handler, func(c *fiber.Ctx) error {
623+
// return c.Next()
624+
// })
621625
//
622626
// This method will match all HTTP verbs: GET, POST, PUT, HEAD etc...
623627
func (app *App) Use(args ...interface{}) Router {
@@ -710,8 +714,9 @@ func (app *App) All(path string, handlers ...Handler) Router {
710714
}
711715

712716
// Group is used for Routes with common prefix to define a new sub-router with optional middleware.
713-
// api := app.Group("/api")
714-
// api.Get("/users", handler)
717+
//
718+
// api := app.Group("/api")
719+
// api.Get("/users", handler)
715720
func (app *App) Group(prefix string, handlers ...Handler) Router {
716721
if len(handlers) > 0 {
717722
app.register(methodUse, prefix, handlers...)

client.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ func (a *Agent) SendFile(filename string, fieldname ...string) *Agent {
566566
// SendFiles reads files and appends them to multipart form request.
567567
//
568568
// Examples:
569-
// SendFile("/path/to/file1", "fieldname1", "/path/to/file2")
569+
//
570+
// SendFile("/path/to/file1", "fieldname1", "/path/to/file2")
570571
func (a *Agent) SendFiles(filenamesAndFieldnames ...string) *Agent {
571572
pairs := len(filenamesAndFieldnames)
572573
if pairs&1 == 1 {

group.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ func (grp *Group) Name(name string) Router {
7070
// Use registers a middleware route that will match requests
7171
// with the provided prefix (which is optional and defaults to "/").
7272
//
73-
// app.Use(func(c *fiber.Ctx) error {
74-
// return c.Next()
75-
// })
76-
// app.Use("/api", func(c *fiber.Ctx) error {
77-
// return c.Next()
78-
// })
79-
// app.Use("/api", handler, func(c *fiber.Ctx) error {
80-
// return c.Next()
81-
// })
73+
// app.Use(func(c *fiber.Ctx) error {
74+
// return c.Next()
75+
// })
76+
// app.Use("/api", func(c *fiber.Ctx) error {
77+
// return c.Next()
78+
// })
79+
// app.Use("/api", handler, func(c *fiber.Ctx) error {
80+
// return c.Next()
81+
// })
8282
//
8383
// This method will match all HTTP verbs: GET, POST, PUT, HEAD etc...
8484
func (grp *Group) Use(args ...interface{}) Router {
@@ -171,8 +171,9 @@ func (grp *Group) All(path string, handlers ...Handler) Router {
171171
}
172172

173173
// Group is used for Routes with common prefix to define a new sub-router with optional middleware.
174-
// api := app.Group("/api")
175-
// api.Get("/users", handler)
174+
//
175+
// api := app.Group("/api")
176+
// api.Get("/users", handler)
176177
func (grp *Group) Group(prefix string, handlers ...Handler) Router {
177178
prefix = getGroupPath(grp.Prefix, prefix)
178179
if len(handlers) > 0 {

internal/fasttemplate/template.go

+24-24
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ func ExecuteFunc(template, startTag, endTag string, w io.Writer, f TagFunc) (int
6565
// values from the map m and writes the result to the given writer w.
6666
//
6767
// Substitution map m may contain values with the following types:
68-
// * []byte - the fastest value type
69-
// * string - convenient value type
70-
// * TagFunc - flexible value type
68+
// - []byte - the fastest value type
69+
// - string - convenient value type
70+
// - TagFunc - flexible value type
7171
//
7272
// Returns the number of bytes written to w.
7373
//
@@ -81,9 +81,9 @@ func Execute(template, startTag, endTag string, w io.Writer, m map[string]interf
8181
// This can be used as a drop-in replacement for strings.Replacer
8282
//
8383
// Substitution map m may contain values with the following types:
84-
// * []byte - the fastest value type
85-
// * string - convenient value type
86-
// * TagFunc - flexible value type
84+
// - []byte - the fastest value type
85+
// - string - convenient value type
86+
// - TagFunc - flexible value type
8787
//
8888
// Returns the number of bytes written to w.
8989
//
@@ -135,9 +135,9 @@ var byteBufferPool bytebufferpool.Pool
135135
// values from the map m and returns the result.
136136
//
137137
// Substitution map m may contain values with the following types:
138-
// * []byte - the fastest value type
139-
// * string - convenient value type
140-
// * TagFunc - flexible value type
138+
// - []byte - the fastest value type
139+
// - string - convenient value type
140+
// - TagFunc - flexible value type
141141
//
142142
// This function is optimized for constantly changing templates.
143143
// Use Template.ExecuteString for frozen templates.
@@ -149,9 +149,9 @@ func ExecuteString(template, startTag, endTag string, m map[string]interface{})
149149
// This can be used as a drop-in replacement for strings.Replacer
150150
//
151151
// Substitution map m may contain values with the following types:
152-
// * []byte - the fastest value type
153-
// * string - convenient value type
154-
// * TagFunc - flexible value type
152+
// - []byte - the fastest value type
153+
// - string - convenient value type
154+
// - TagFunc - flexible value type
155155
//
156156
// This function is optimized for constantly changing templates.
157157
// Use Template.ExecuteStringStd for frozen templates.
@@ -305,9 +305,9 @@ func (t *Template) ExecuteFunc(w io.Writer, f TagFunc) (int64, error) {
305305
// values from the map m and writes the result to the given writer w.
306306
//
307307
// Substitution map m may contain values with the following types:
308-
// * []byte - the fastest value type
309-
// * string - convenient value type
310-
// * TagFunc - flexible value type
308+
// - []byte - the fastest value type
309+
// - string - convenient value type
310+
// - TagFunc - flexible value type
311311
//
312312
// Returns the number of bytes written to w.
313313
func (t *Template) Execute(w io.Writer, m map[string]interface{}) (int64, error) {
@@ -318,9 +318,9 @@ func (t *Template) Execute(w io.Writer, m map[string]interface{}) (int64, error)
318318
// This can be used as a drop-in replacement for strings.Replacer
319319
//
320320
// Substitution map m may contain values with the following types:
321-
// * []byte - the fastest value type
322-
// * string - convenient value type
323-
// * TagFunc - flexible value type
321+
// - []byte - the fastest value type
322+
// - string - convenient value type
323+
// - TagFunc - flexible value type
324324
//
325325
// Returns the number of bytes written to w.
326326
func (t *Template) ExecuteStd(w io.Writer, m map[string]interface{}) (int64, error) {
@@ -366,9 +366,9 @@ func (t *Template) ExecuteFuncStringWithErr(f TagFunc) (string, error) {
366366
// values from the map m and returns the result.
367367
//
368368
// Substitution map m may contain values with the following types:
369-
// * []byte - the fastest value type
370-
// * string - convenient value type
371-
// * TagFunc - flexible value type
369+
// - []byte - the fastest value type
370+
// - string - convenient value type
371+
// - TagFunc - flexible value type
372372
//
373373
// This function is optimized for frozen templates.
374374
// Use ExecuteString for constantly changing templates.
@@ -380,9 +380,9 @@ func (t *Template) ExecuteString(m map[string]interface{}) string {
380380
// This can be used as a drop-in replacement for strings.Replacer
381381
//
382382
// Substitution map m may contain values with the following types:
383-
// * []byte - the fastest value type
384-
// * string - convenient value type
385-
// * TagFunc - flexible value type
383+
// - []byte - the fastest value type
384+
// - string - convenient value type
385+
// - TagFunc - flexible value type
386386
//
387387
// This function is optimized for frozen templates.
388388
// Use ExecuteStringStd for constantly changing templates.

internal/fwd/reader.go

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
// returns a slice pointing to the next `n` bytes of the writer, and increments
3232
// the write position by the length of the returned slice. This allows users
3333
// to write directly to the end of the buffer.
34-
//
3534
package fwd
3635

3736
import "io"

internal/go-ole/guid.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ type GUID struct {
108108
//
109109
// The supplied string may be in any of these formats:
110110
//
111-
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
112-
// XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
113-
// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
111+
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
112+
// XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
113+
// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
114114
//
115115
// The conversion of the supplied string is not case-sensitive.
116116
func NewGUID(guid string) *GUID {
@@ -216,11 +216,11 @@ func decodeHexChar(c byte) (byte, bool) {
216216

217217
// String converts the GUID to string form. It will adhere to this pattern:
218218
//
219-
// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
219+
// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
220220
//
221221
// If the GUID is nil, the string representation of an empty GUID is returned:
222222
//
223-
// {00000000-0000-0000-0000-000000000000}
223+
// {00000000-0000-0000-0000-000000000000}
224224
func (guid *GUID) String() string {
225225
if guid == nil {
226226
return emptyGUID

internal/gopsutil/common/common.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ func ReadLines(filename string) ([]string, error) {
114114
// ReadLines reads contents from file and splits them by new line.
115115
// The offset tells at which line number to start.
116116
// The count determines the number of lines to read (starting from offset):
117-
// n >= 0: at most n lines
118-
// n < 0: whole file
117+
//
118+
// n >= 0: at most n lines
119+
// n < 0: whole file
119120
func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
120121
f, err := os.Open(filename)
121122
if err != nil {
@@ -308,7 +309,7 @@ func PathExists(filename string) bool {
308309
return false
309310
}
310311

311-
//GetEnv retrieves the environment variable key. If it does not exist it returns the default.
312+
// GetEnv retrieves the environment variable key. If it does not exist it returns the default.
312313
func GetEnv(key string, dfault string, combineWith ...string) string {
313314
value := os.Getenv(key)
314315
if value == "" {

internal/gopsutil/common/common_windows.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,12 @@ func WMIQueryWithContext(ctx context.Context, query string, dst interface{}, con
211211
}
212212

213213
// Convert paths using native DOS format like:
214-
// "\Device\HarddiskVolume1\Windows\systemew\file.txt"
214+
//
215+
// "\Device\HarddiskVolume1\Windows\systemew\file.txt"
216+
//
215217
// into:
216-
// "C:\Windows\systemew\file.txt"
218+
//
219+
// "C:\Windows\systemew\file.txt"
217220
func ConvertDOSPath(p string) string {
218221
rawDrive := strings.Join(strings.Split(p, `\`)[:3], `\`)
219222

internal/gopsutil/cpu/cpu_solaris.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func init() {
2929
}
3030
}
3131

32-
//sum all values in a float64 map with float64 keys
32+
// sum all values in a float64 map with float64 keys
3333
func msum(x map[float64]float64) float64 {
3434
total := 0.0
3535
for _, y := range x {

internal/gopsutil/net/net_linux.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ var netProtocols = []string{
161161
// If protocols is empty then all protocols are returned, otherwise
162162
// just the protocols in the list are returned.
163163
// Available protocols:
164-
// ip,icmp,icmpmsg,tcp,udp,udplite
164+
//
165+
// ip,icmp,icmpmsg,tcp,udp,udplite
165166
func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
166167
return ProtoCountersWithContext(context.Background(), protocols)
167168
}

internal/gopsutil/net/net_windows.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename stri
208208

209209
// Return a list of network connections
210210
// Available kind:
211-
// reference to netConnectionKindMap
211+
//
212+
// reference to netConnectionKindMap
212213
func Connections(kind string) ([]ConnectionStat, error) {
213214
return ConnectionsWithContext(context.Background(), kind)
214215
}

internal/isatty/isatty_windows.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ func IsTerminal(fd uintptr) bool {
4242

4343
// Check pipe name is used for cygwin/msys2 pty.
4444
// Cygwin/MSYS2 PTY has a name like:
45-
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
45+
//
46+
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
4647
func isCygwinPipeName(name string) bool {
4748
token := strings.Split(name, "-")
4849
if len(token) < 5 {

internal/msgp/defs.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
// generator implement the Marshaler/Unmarshaler and Encodable/Decodable interfaces.
66
//
77
// This package defines four "families" of functions:
8-
// - AppendXxxx() appends an object to a []byte in MessagePack encoding.
9-
// - ReadXxxxBytes() reads an object from a []byte and returns the remaining bytes.
10-
// - (*Writer).WriteXxxx() writes an object to the buffered *Writer type.
11-
// - (*Reader).ReadXxxx() reads an object from a buffered *Reader type.
8+
// - AppendXxxx() appends an object to a []byte in MessagePack encoding.
9+
// - ReadXxxxBytes() reads an object from a []byte and returns the remaining bytes.
10+
// - (*Writer).WriteXxxx() writes an object to the buffered *Writer type.
11+
// - (*Reader).ReadXxxx() reads an object from a buffered *Reader type.
1212
//
1313
// Once a type has satisfied the `Encodable` and `Decodable` interfaces,
1414
// it can be written and read from arbitrary `io.Writer`s and `io.Reader`s using
15-
// msgp.Encode(io.Writer, msgp.Encodable)
15+
//
16+
// msgp.Encode(io.Writer, msgp.Encodable)
17+
//
1618
// and
17-
// msgp.Decode(io.Reader, msgp.Decodable)
19+
//
20+
// msgp.Decode(io.Reader, msgp.Decodable)
1821
//
1922
// There are also methods for converting MessagePack to JSON without
2023
// an explicit de-serialization step.

internal/msgp/elsize.go

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package msgp
44
// plus type information. gives us
55
// constant-time type information
66
// for traversing composite objects.
7-
//
87
var sizes = [256]bytespec{
98
mnil: {size: 1, extra: constsize, typ: NilType},
109
mfalse: {size: 1, extra: constsize, typ: BoolType},

internal/msgp/errors.go

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func Resumable(e error) bool {
7070
//
7171
// ErrShortBytes is not wrapped with any context due to backward compatibility
7272
// issues with the public API.
73-
//
7473
func WrapError(err error, ctx ...interface{}) error {
7574
switch e := err.(type) {
7675
case errShort:

internal/msgp/extension.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var extensionReg = make(map[int8]func() Extension)
3030
//
3131
// For example, if you wanted to register a user-defined struct:
3232
//
33-
// msgp.RegisterExtension(10, func() msgp.Extension { &MyExtension{} })
33+
// msgp.RegisterExtension(10, func() msgp.Extension { &MyExtension{} })
3434
//
3535
// RegisterExtension will panic if you call it multiple times
3636
// with the same 'typ' argument, or if you use a reserved

0 commit comments

Comments
 (0)