forked from huandu/facebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.go
57 lines (47 loc) · 964 Bytes
/
misc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// A facebook graph api client in go.
// https://github.com/huandu/facebook/
//
// Copyright 2012 - 2014, Huan Du
// Licensed under the MIT license
// https://github.com/huandu/facebook/blob/master/LICENSE
package facebook
import (
"bytes"
"io"
"unicode"
)
func camelCaseToUnderScore(name string) string {
if name == "" {
return ""
}
buf := &bytes.Buffer{}
for _, r := range name {
if unicode.IsUpper(r) {
if buf.Len() != 0 {
buf.WriteRune('_')
}
buf.WriteRune(unicode.ToLower(r))
} else {
buf.WriteRune(r)
}
}
return buf.String()
}
// Returns error string.
func (e *Error) Error() string {
return e.Message
}
// Creates a new binary data holder.
func Data(filename string, source io.Reader) *BinaryData {
return &BinaryData{
Filename: filename,
Source: source,
}
}
// Creates a binary file holder.
func File(filename, path string) *BinaryFile {
return &BinaryFile{
Filename: filename,
Path: path,
}
}