diff options
author | Shulhan <ms@kilabit.info> | 2019-02-02 18:13:33 +0700 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2019-02-02 11:13:33 +0000 |
commit | 9574c37fb8573364003841d9b523ee7df95aedc8 (patch) | |
tree | 10652140e87660fffe669ed0fedc5a843aba3cc7 /fs_test.go | |
parent | all: fix typo on comments (diff) | |
download | fasthttp-9574c37fb8573364003841d9b523ee7df95aedc8.tar.gz fasthttp-9574c37fb8573364003841d9b523ee7df95aedc8.tar.bz2 fasthttp-9574c37fb8573364003841d9b523ee7df95aedc8.zip |
Various changes regarding code readibility (#523)
* all: use sort.Strings when applicable
Basically, sort.Strings is the shortcut of Sort(StringSlice(a)) but its
more readable.
* all: replace string(bytes.Buffer.Bytes()) with bytes.Buffer.String()
Although its only occured on test files, it may be worth to simplified it.
* http_test: simplify strings.Index with strings.Contains
Both have the same O(n), but strings.Contains more readable on
if-condition.
* args: simplify if-condition check on boolean value
* all: simplify variable initialization
If we assign the variable after declaring it, we can simplify it using
":=" operator or "= value".
The reader can still known the type of variable from the struct name or
variable type before assignment operator.
Diffstat (limited to 'fs_test.go')
-rw-r--r-- | fs_test.go | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -172,7 +172,7 @@ func TestServeFileSmallNoReadFrom(t *testing.T) { t.Fatalf("expected %d bytes, got %d bytes", len(teststr), n) } - body := string(buf.Bytes()) + body := buf.String() if body != teststr { t.Fatalf("expected '%s'", teststr) } @@ -534,7 +534,7 @@ func TestFSHandlerSingleThread(t *testing.T) { if err != nil { t.Fatalf("cannot read dirnames in cwd: %s", err) } - sort.Sort(sort.StringSlice(filenames)) + sort.Strings(filenames) for i := 0; i < 3; i++ { fsHandlerTest(t, requestHandler, filenames) @@ -554,7 +554,7 @@ func TestFSHandlerConcurrent(t *testing.T) { if err != nil { t.Fatalf("cannot read dirnames in cwd: %s", err) } - sort.Sort(sort.StringSlice(filenames)) + sort.Strings(filenames) concurrency := 10 ch := make(chan struct{}, concurrency) |