afffa668a9
-Removed dependency on internal apis -Moved over only required packages. -Adjusted slack.go to be generic instead of hard coding channel name. -Moved over travis package from internal-apis -Added Repository struct for webhook and an IsMatch method. It is possible for any repository to send a webhook to the api and it will trigger a deploy. We should check against the owner, repo and branch. -Renamed package to api -removed util.Debugging from server.go -Added an ErrorHandling function that be used as interface for slack for internal-apis -Added Map for Header settings that can be set before the serving -Merged slack code from lbryio/boardbot -Cleaned up the slack.go code so it made more sense and flowed better -Removed gitignore entry for `.idea`, should be global -Removed debugging.go -Added option for private vs public repository for getting travis public key. -separated private vs public into if else. -Changed HeaderSettings to not be pointer. -Changed ErrorHandler to be named LogErrorFunc -removed logrus dependency, created loginfo function to handle non-error information. -Added Daemon Types and adjusted peer_list to be in line with v20 -Fixed rpcclient library usage for latest version to prevent build errors. -Changed inputs to LogError and LogInfo so that other implementations can make this customizable.
33 lines
675 B
Go
33 lines
675 B
Go
package util
|
|
|
|
// https://github.com/go-pg/pg/blob/7c2d9d39a5cfc18a422c88a9f5f39d8d2cd10030/internal/underscore.go
|
|
|
|
func isUpper(c byte) bool {
|
|
return c >= 'A' && c <= 'Z'
|
|
}
|
|
|
|
func isLower(c byte) bool {
|
|
return !isUpper(c)
|
|
}
|
|
|
|
func toLower(c byte) byte {
|
|
return c + 32
|
|
}
|
|
|
|
// Underscore converts "CamelCasedString" to "camel_cased_string".
|
|
func Underscore(s string) string {
|
|
r := make([]byte, 0, len(s))
|
|
for i := 0; i < len(s); i++ {
|
|
c := s[i]
|
|
if isUpper(c) {
|
|
if i > 0 && i+1 < len(s) && (isLower(s[i-1]) || isLower(s[i+1])) {
|
|
r = append(r, '_', toLower(c))
|
|
} else {
|
|
r = append(r, toLower(c))
|
|
}
|
|
} else {
|
|
r = append(r, c)
|
|
}
|
|
}
|
|
return string(r)
|
|
}
|