Skip to content

Commit

Permalink
_content/doc: fix inconsistent tabs in code snippets
Browse files Browse the repository at this point in the history
Replace real tabs with 4 spaces in code snippets to make indentation
consistent

Fixes golang/go#52255

Change-Id: Ida06a1dd2c2cd3100c32d6c29febf60aba2e20d7
Reviewed-on: https://go-review.googlesource.com/c/website/+/399374
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
  • Loading branch information
looshch authored and jamalc committed May 24, 2022
1 parent 9e1b9c7 commit f66592d
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 101 deletions.
26 changes: 13 additions & 13 deletions _content/doc/articles/wiki/index.html
Expand Up @@ -54,8 +54,8 @@ <h2>Getting Started</h2>
package main

import (
"fmt"
"os"
"fmt"
"os"
)
</pre>

Expand Down Expand Up @@ -255,10 +255,10 @@ <h2>Using <code>net/http</code> to serve wiki pages</h2>

<pre>
import (
"fmt"
"os"
"log"
<b>"net/http"</b>
"fmt"
"os"
"log"
<b>"net/http"</b>
)
</pre>

Expand Down Expand Up @@ -371,9 +371,9 @@ <h2>The <code>html/template</code> package</h2>

<pre>
import (
<b>"html/template"</b>
"os"
"net/http"
<b>"html/template"</b>
"os"
"net/http"
)
</pre>

Expand Down Expand Up @@ -649,10 +649,10 @@ <h2>Introducing Function Literals and Closures</h2>

<pre>
func makeHandler(fn func (http.ResponseWriter, *http.Request, string)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Here we will extract the page title from the Request,
// and call the provided handler 'fn'
}
return func(w http.ResponseWriter, r *http.Request) {
// Here we will extract the page title from the Request,
// and call the provided handler 'fn'
}
}
</pre>

Expand Down
58 changes: 29 additions & 29 deletions _content/doc/code.html
Expand Up @@ -99,7 +99,7 @@ <h2 id="Command">Your first program</h2>
import "fmt"

func main() {
fmt.Println("Hello, world.")
fmt.Println("Hello, world.")
}
</pre>

Expand Down Expand Up @@ -230,11 +230,11 @@ <h3 id="ImportingLocal">Importing packages from your module</h3>

// ReverseRunes returns its argument string reversed rune-wise left to right.
func ReverseRunes(s string) string {
r := []rune(s)
for i, j := 0, len(r)-1; i &lt; len(r)/2; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
return string(r)
r := []rune(s)
for i, j := 0, len(r)-1; i &lt; len(r)/2; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
return string(r)
}
</pre>

Expand Down Expand Up @@ -270,13 +270,13 @@ <h3 id="ImportingLocal">Importing packages from your module</h3>
package main

import (
"fmt"
"fmt"

<b>"example/user/hello/morestrings"</b>
<b>"example/user/hello/morestrings"</b>
)

func main() {
fmt.Println(morestrings.ReverseRunes("!oG ,olleH"))
fmt.Println(morestrings.ReverseRunes("!oG ,olleH"))
}
</pre>

Expand Down Expand Up @@ -310,15 +310,15 @@ <h3 id="ImportingRemote">Importing packages from remote modules</h3>
package main

import (
"fmt"
"fmt"

"example/user/hello/morestrings"
"github.com/google/go-cmp/cmp"
"example/user/hello/morestrings"
"github.com/google/go-cmp/cmp"
)

func main() {
fmt.Println(morestrings.ReverseRunes("!oG ,olleH"))
fmt.Println(cmp.Diff("Hello World", "Hello Go"))
fmt.Println(morestrings.ReverseRunes("!oG ,olleH"))
fmt.Println(cmp.Diff("Hello World", "Hello Go"))
}
</pre>

Expand All @@ -337,8 +337,8 @@ <h3 id="ImportingRemote">Importing packages from remote modules</h3>
$ hello
Hello, Go!
string(
- "Hello World",
+ "Hello Go",
- "Hello World",
+ "Hello Go",
)
$ cat go.mod
module example/user/hello
Expand Down Expand Up @@ -392,19 +392,19 @@ <h2 id="Testing">Testing</h2>
import "testing"

func TestReverseRunes(t *testing.T) {
cases := []struct {
in, want string
}{
{"Hello, world", "dlrow ,olleH"},
{"Hello, 世界", "界世 ,olleH"},
{"", ""},
}
for _, c := range cases {
got := ReverseRunes(c.in)
if got != c.want {
t.Errorf("ReverseRunes(%q) == %q, want %q", c.in, got, c.want)
}
}
cases := []struct {
in, want string
}{
{"Hello, world", "dlrow ,olleH"},
{"Hello, 世界", "界世 ,olleH"},
{"", ""},
}
for _, c := range cases {
got := ReverseRunes(c.in)
if got != c.want {
t.Errorf("ReverseRunes(%q) == %q, want %q", c.in, got, c.want)
}
}
}
</pre>

Expand Down
54 changes: 27 additions & 27 deletions _content/doc/effective_go.html
Expand Up @@ -815,27 +815,27 @@ <h3 id="switch">Switch</h3>

<pre>
Loop:
for n := 0; n &lt; len(src); n += size {
switch {
case src[n] &lt; sizeOne:
if validateOnly {
break
}
size = 1
update(src[n])

case src[n] &lt; sizeTwo:
if n+1 &gt;= len(src) {
err = errShortInput
break Loop
}
if validateOnly {
break
}
size = 2
update(src[n] + src[n+1]&lt;&lt;shift)
}
}
for n := 0; n &lt; len(src); n += size {
switch {
case src[n] &lt; sizeOne:
if validateOnly {
break
}
size = 1
update(src[n])

case src[n] &lt; sizeTwo:
if n+1 &gt;= len(src) {
err = errShortInput
break Loop
}
if validateOnly {
break
}
size = 2
update(src[n] + src[n+1]&lt;&lt;shift)
}
}
</pre>

<p>
Expand Down Expand Up @@ -1490,9 +1490,9 @@ <h3 id="two_dimensional_slices">Two-dimensional slices</h3>

<pre>
text := LinesOfText{
[]byte("Now is the time"),
[]byte("for all good gophers"),
[]byte("to bring some fun to the party."),
[]byte("Now is the time"),
[]byte("for all good gophers"),
[]byte("to bring some fun to the party."),
}
</pre>

Expand All @@ -1515,7 +1515,7 @@ <h3 id="two_dimensional_slices">Two-dimensional slices</h3>
picture := make([][]uint8, YSize) // One row per unit of y.
// Loop over the rows, allocating the slice for each row.
for i := range picture {
picture[i] = make([]uint8, XSize)
picture[i] = make([]uint8, XSize)
}
</pre>

Expand All @@ -1530,7 +1530,7 @@ <h3 id="two_dimensional_slices">Two-dimensional slices</h3>
pixels := make([]uint8, XSize*YSize) // Has type []uint8 even though picture is [][]uint8.
// Loop over the rows, slicing each row from the front of the remaining pixels slice.
for i := range picture {
picture[i], pixels = pixels[:XSize], pixels[XSize:]
picture[i], pixels = pixels[:XSize], pixels[XSize:]
}
</pre>

Expand Down Expand Up @@ -2520,7 +2520,7 @@ <h3 id="blank_assign">The blank identifier in multiple assignment</h3>

<pre>
if _, err := os.Stat(path); os.IsNotExist(err) {
fmt.Printf("%s does not exist\n", path)
fmt.Printf("%s does not exist\n", path)
}
</pre>

Expand Down
22 changes: 11 additions & 11 deletions _content/doc/faq.html
Expand Up @@ -966,11 +966,11 @@ <h3 id="nil_error">

<pre>
func returnsError() error {
var p *MyError = nil
if bad() {
p = ErrBad
}
return p // Will always return a non-nil error.
var p *MyError = nil
if bad() {
p = ErrBad
}
return p // Will always return a non-nil error.
}
</pre>

Expand All @@ -987,10 +987,10 @@ <h3 id="nil_error">

<pre>
func returnsError() error {
if bad() {
return ErrBad
}
return nil
if bad() {
return ErrBad
}
return nil
}
</pre>

Expand Down Expand Up @@ -1060,7 +1060,7 @@ <h3 id="covariant_types">

<pre>
type Copyable interface {
Copy() interface{}
Copy() interface{}
}
</pre>

Expand Down Expand Up @@ -2096,7 +2096,7 @@ <h3 id="types_in_method_declaration">
type S[T any] struct { f T }

func (s S[string]) Add(t string) string {
return s.f + t
return s.f + t
}
</pre>

Expand Down
42 changes: 21 additions & 21 deletions _content/ref/mod.md
Expand Up @@ -788,8 +788,8 @@ publishes version `v1.0.0` accidentally. To prevent users from upgrading to

```
retract (
v1.0.0 // Published accidentally.
v1.0.1 // Contains retractions only.
v1.0.0 // Published accidentally.
v1.0.1 // Contains retractions only.
)
```

Expand Down Expand Up @@ -1941,33 +1941,33 @@ The editing flags may be repeated. The changes are applied in the order given.

```
type Module struct {
Path string
Version string
Path string
Version string
}
type GoMod struct {
Module Module
Go string
Require []Require
Exclude []Module
Replace []Replace
Module Module
Go string
Require []Require
Exclude []Module
Replace []Replace
}
type Require struct {
Path string
Version string
Indirect bool
Path string
Version string
Indirect bool
}
type Replace struct {
Old Module
New Module
Old Module
New Module
}
type Retract struct {
Low string
High string
Rationale string
Low string
High string
Rationale string
}
```
Expand Down Expand Up @@ -2820,9 +2820,9 @@ module golang.org/x/mod
go 1.12
require (
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
)
```

Expand Down Expand Up @@ -4563,4 +4563,4 @@ letter `v` followed by a semantic version. See the section on
<a id="glos-workspace"></a>
**workspace:** A collection of modules on disk that are used as
the root modules when running [minimal version selection (MVS)](#minimal-version-selection).
See the section on [Workspaces](#workspaces)
See the section on [Workspaces](#workspaces)

0 comments on commit f66592d

Please sign in to comment.