strings.Replace(name, "_", "-", -1)
8 }
9
10 // replace underscores with dashes
11 name = strings.Replace(name, "_", "-", -1)12
13 // myapp -> Myapp; my-app -> MyApp
14 us := strings.ToUpper(name[0:1]) + name[1:]
bytes.Replace(markdown, n[2], np, -1)
266 blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs|blackfriday.LaxHTMLBlocks),
267 )
268
269 markdown = bytes.Replace(markdown, n[2], np, -1)270 }
271
272 parsed := blackfriday.Run(markdown,
strings.Replace(name, ".", "-", -1)
217func parseDocument(path string, data []byte) (*Document, error) {
218 name := strings.TrimSuffix(path, ".md")
219 readme := strings.HasSuffix(path, "/README.md")
220 slug := strings.TrimSuffix(strings.Replace(name, ".", "-", -1), "/README")221
222 d := &Document{
223 Path: path,
bytes.Replace(data, []byte("{\n\n"), []byte("{\n"), -1)
14 return nil, err
15 }
16
17 data = bytes.Replace(data, []byte("{\n\n"), []byte("{\n"), -1)18 data = bytes.Replace(data, []byte("\n\n}"), []byte("\n}"), -1)
19 data = bytes.Replace(data, []byte("\n\n\tr.Route"), []byte("\n\tr.Route"), -1)
20
bytes.Replace(data, []byte("\n\n}"), []byte("\n}"), -1)
15 }
16
17 data = bytes.Replace(data, []byte("{\n\n"), []byte("{\n"), -1)
18 data = bytes.Replace(data, []byte("\n\n}"), []byte("\n}"), -1)19 data = bytes.Replace(data, []byte("\n\n\tr.Route"), []byte("\n\tr.Route"), -1)
20
21 return data, nil
Certain functions, for a particular set of arguments, have shorthands (helpers) that can be used instead.
We currently support Autofix for, Format: x => y where "x" is recommended to be replaced with "y" helper function.
Supported Autofix for the following: strings.SplitN(s, ".", -1) => strings.Split(s, ".") strings.Map(unicode.ToTitle, s) => strings.ToTitle(s) strings.Replace(s, "a", "b", -1) => strings.ReplaceAll(s, "a", "b") bytes.SplitN(b, []byte("."), -1) => bytes.Split(b, []byte(".")) bytes.Map(unicode.ToUpper, b) => bytes.ToUpper(b) bytes.Map(unicode.ToLower, b) => bytes.ToLower(b) bytes.Map(unicode.ToTitle, b) => bytes.ToTitle(b) bytes.Replace(b, b, b, -1) => bytes.ReplaceAll(b, b, b) http.HandlerFunc(http.NotFound) => http.NotFoundHandler() draw.DrawMask(i, r, i, p, nil, image.Point{}, o) => draw.Draw(i, r, i, p, o)
wg.Add(1)
// some code
wg.Add(-1)
wg.Add(1)
// some code
wg.Done()
strings.SplitN(str, splitChar, -1)
strings.Split(str, splitChar)
http.HandlerFunc("/non-existent", http404)
http.NotFoundHandler("/non-existent")