You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
717 B
34 lines
717 B
package main |
|
|
|
import ( |
|
"fmt" |
|
"strings" |
|
|
|
"golang.org/x/tools/imports" |
|
) |
|
|
|
// GoImport Use golang.org/x/tools/imports auto import pkg |
|
func GoImport(file string, bytes []byte) (res []byte, err error) { |
|
options := &imports.Options{ |
|
TabWidth: 8, |
|
TabIndent: true, |
|
Comments: true, |
|
Fragment: true, |
|
} |
|
if res, err = imports.Process(file, bytes, options); err != nil { |
|
fmt.Printf("GoImport(%s) error(%v)", file, err) |
|
res = bytes |
|
return |
|
} |
|
return |
|
} |
|
|
|
// IsService checkout the file belongs to service or not |
|
func IsService(pName string) bool { |
|
return pName == "service" |
|
} |
|
|
|
//ConvertHump convert words to hump style |
|
func ConvertHump(words string) string { |
|
return strings.ToUpper(words[0:1]) + words[1:] |
|
}
|
|
|