Skip to content

Commit 49f7fde

Browse files
committed
change variable and function names to camelCase
1 parent 4a29507 commit 49f7fde

10 files changed

Lines changed: 284 additions & 288 deletions

File tree

src/fs/debug_info.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ import (
1717
type debugInfo struct {
1818
last time.Time
1919

20-
num_requests_received, num_requests_served, num_bytes_served int64
20+
numRequestsReceived, numRequestsServed, numBytesServed int64
2121

2222
sync.RWMutex
2323
}
2424

25-
func (this *debugInfo) everything() (last_served_time time.Time, num_received, num_served, bytes_served int64) {
26-
this.RLock()
27-
last_served_time = this.last
28-
num_received = this.num_requests_received
29-
num_served = this.num_requests_served
30-
bytes_served = this.num_bytes_served
31-
this.RUnlock()
25+
func (d *debugInfo) everything() (lastServedTime time.Time, numReceived, numServed, bytesServed int64) {
26+
d.RLock()
27+
lastServedTime = d.last
28+
numReceived = d.numRequestsReceived
29+
numServed = d.numRequestsServed
30+
bytesServed = d.numBytesServed
31+
d.RUnlock()
3232
return
3333
}
3434

35-
func (this *debugInfo) requestServed(bytes_served int64) {
36-
this.Lock()
37-
this.num_requests_served++
38-
this.num_bytes_served += bytes_served
39-
this.last = time.Now()
40-
this.Unlock()
35+
func (d *debugInfo) requestServed(bytesServed int64) {
36+
d.Lock()
37+
d.numRequestsServed++
38+
d.numBytesServed += bytesServed
39+
d.last = time.Now()
40+
d.Unlock()
4141
}

src/fs/file_info.go

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import (
2121
)
2222

2323
type fileInfo struct {
24-
name string
25-
mime_type string
26-
mtime time.Time
27-
size int64
24+
name string
25+
mimeType string
26+
mtime time.Time
27+
size int64
2828
}
2929

3030
type fileSorter struct {
@@ -46,53 +46,54 @@ func (fi *fileSorter) Less(i, j int) bool {
4646
return strings.ToLower(fi.files[i].name) < strings.ToLower(fi.files[j].name)
4747
}
4848

49-
func (this *fileInfo) to_json() string {
50-
name, _ := json.Marshal(this.name)
51-
return fmt.Sprintf(`{"name": %s, "mime_type": "%s", "mtime": "%s", "size": %d}`, string(name), this.mime_type, this.mtime.Format(http.TimeFormat), this.size)
49+
func (f *fileInfo) toJson() string {
50+
name, _ := json.Marshal(f.name)
51+
return fmt.Sprintf(`{"name": %s, "mime_type": "%s", "mtime": "%s", "size": %d}`,
52+
string(name), f.mimeType, f.mtime.Format(http.TimeFormat), f.size)
5253
}
5354

54-
func directory_fileInfos(fis []os.FileInfo, full_path string) []fileInfo {
55-
file_infos := []fileInfo{}
55+
func directoryFileInfos(fis []os.FileInfo, fullPath string) []fileInfo {
56+
fileInfos := make([]fileInfo, 0)
5657
for i := range fis {
5758
if fis[i].Name()[0] == '.' {
5859
continue
5960
}
60-
fileInfo := fileInfo {
61+
fileInfo := fileInfo{
6162
name: fis[i].Name(),
6263
mtime: fis[i].ModTime(),
6364
}
64-
if fis[i].IsDir() || isSymlinkDir(fis[i], full_path) {
65-
fileInfo.mime_type = "text/directory"
65+
if fis[i].IsDir() || isSymlinkDir(fis[i], fullPath) {
66+
fileInfo.mimeType = "text/directory"
6667
fileInfo.size = 0
6768
} else {
68-
fileInfo.mime_type = getContentType(fis[i].Name())
69+
fileInfo.mimeType = getContentType(fis[i].Name())
6970
fileInfo.size = fis[i].Size()
7071
}
71-
file_infos = append(file_infos, fileInfo)
72+
fileInfos = append(fileInfos, fileInfo)
7273
}
7374

74-
sorter := &fileSorter{files: file_infos}
75+
sorter := &fileSorter{files: fileInfos}
7576

7677
sort.Sort(sorter)
7778

78-
return file_infos
79+
return fileInfos
7980
}
8081

81-
func dirToJSON(osFile *os.File, full_path string) (string, error) {
82+
func dirToJSON(osFile *os.File, fullPath string) (string, error) {
8283
fis, err := osFile.Readdir(0)
8384
if err != nil {
8485
return "", err
8586
}
8687

87-
file_infos := directory_fileInfos(fis, full_path)
88+
fileInfos := directoryFileInfos(fis, fullPath)
8889

89-
if len(file_infos) == 0 {
90+
if len(fileInfos) == 0 {
9091
return "[]", nil
9192
}
9293

93-
ss := []string{}
94-
for i := range file_infos {
95-
temp := file_infos[i].to_json()
94+
ss := make([]string, 0)
95+
for i := range fileInfos {
96+
temp := fileInfos[i].toJson()
9697
ss = append(ss, temp)
9798
}
9899

@@ -140,7 +141,7 @@ func getContentType(fileName string) string {
140141
".wtv": "video/x-ms-wtv",
141142
".flv": "video/x-flv",
142143
".3gp": "video/3gpp",
143-
".webm": "video/webm",
144+
".webm": "video/webm",
144145
".epub": "application/epub+zip",
145146
".mobi": "application/x-mobipocket",
146147
".zip": "application/zip",
@@ -173,12 +174,12 @@ func getContentType(fileName string) string {
173174
".html": "text/html",
174175
".htm": "text/html",
175176
// subtitle stuff, with others below
176-
".srt": "application/x-subrip",
177-
".sub": "text/vnd.dvb.subtitle",
177+
".srt": "application/x-subrip",
178+
".sub": "text/vnd.dvb.subtitle",
178179
}
179180

180-
sub_extensions := []string{".idx", ".sub", ".srt", ".ssa", ".ass", ".smi", ".utf", ".utf8", ".utf-8", ".rt", ".aqt", ".usf", ".jss", ".cdg", ".psb", ".mpsub", ".mpl2", ".pjs", ".dks", ".stl", ".vtt"}
181-
for _, e := range sub_extensions {
181+
subExtensions := []string{".idx", ".sub", ".srt", ".ssa", ".ass", ".smi", ".utf", ".utf8", ".utf-8", ".rt", ".aqt", ".usf", ".jss", ".cdg", ".psb", ".mpsub", ".mpl2", ".pjs", ".dks", ".stl", ".vtt"}
182+
for _, e := range subExtensions {
182183
encodingMap[e] = "application/x-subtitle"
183184
}
184185

0 commit comments

Comments
 (0)