Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mazrean committed May 28, 2020
1 parent 88cf7f7 commit e7943a5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 39 deletions.
46 changes: 23 additions & 23 deletions boiler/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func NewCode(basePath string, yaml *model.Yaml) (*Code, error) {
}

column := &model.CodeColumn{
Name: name,
Type: goType,
Null: v.Null,
Name: name,
Type: goType,
Null: v.Null,
ReadOnly: v.AutoIncrement,
}
columns = append(columns, column)
Expand All @@ -54,7 +54,7 @@ func NewCode(basePath string, yaml *model.Yaml) (*Code, error) {
boilBase := base.NewBoilBase(basePath)
code := &Code{
BoilerBase: boilBase,
Code: codeContainer,
Code: codeContainer,
}
return code, nil
}
Expand All @@ -73,33 +73,33 @@ func (c *Code) BoilCode() error {
return nil
}

func typeParser(sqlType string) (string,error) {
typeMap := map[string]string {
"boolean": "bool",
"char": "string",
"varchar": "string",
"binary": "string",
func typeParser(sqlType string) (string, error) {
typeMap := map[string]string{
"boolean": "bool",
"char": "string",
"varchar": "string",
"binary": "string",
"varbinary": "string",
"blob": "blob",
"text": "string",
"integer": "int32",
"int": "int32",
"bigint": "int64",
"blob": "blob",
"text": "string",
"integer": "int32",
"int": "int32",
"bigint": "int64",
"mediumint": "int32",
"smallint": "int16",
"tinyint": "int8",
"date": "timeTime",
"datetime": "timeTime",
"smallint": "int16",
"tinyint": "int8",
"date": "timeTime",
"datetime": "timeTime",
"timestamp": "timeTime",
"time": "timeTime",
"year": "timeTime",
"time": "timeTime",
"year": "timeTime",
}

var buf bytes.Buffer
isStringfied := false
for _,c := range sqlType {
for _, c := range sqlType {
if (c < 'a' || 'z' < c) && (c < '0' || '9' < c) && c != '(' && c != ')' {
return "",fmt.Errorf("%s In Type %s Should Be Lower Case", string(c), sqlType)
return "", fmt.Errorf("%s In Type %s Should Be Lower Case", string(c), sqlType)
}
if c == '(' && !isStringfied {
sqlType = buf.String()
Expand Down
4 changes: 2 additions & 2 deletions cmd/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type codeOptions struct {
yamlPath string
yamlPath string
codePath string
}

Expand All @@ -20,7 +20,7 @@ var (
var codeCmd = &cobra.Command{
Use: "code",
Short: "コードの生成",
Long: `コードの生成のみ行います。`,
Long: `コードの生成のみ行います。`,
RunE: func(cmd *cobra.Command, args []string) error {
yaml, err := boiler.NewYaml(codeOpt.yamlPath)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions model/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package model

// Code コード生成用の構造体
type Code struct {
DB db
DB db
Tables []*CodeTable
}

// CodeTable テーブルの構造体
type CodeTable struct {
Name *NameDetail
Name *NameDetail
Columns []*CodeColumn
}

// CodeColumn カラムの構造体
type CodeColumn struct {
Name *NameDetail
Type string
Null bool
ReadOnly bool
}
Name *NameDetail
Type string
Null bool
ReadOnly bool
}
6 changes: 3 additions & 3 deletions model/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type db struct {
type NameDetail struct {
UpperCamel string
LowerCamel string
Snake string
Snake string
}

// NewNameDetail NameDeatailのコンストラクタ
Expand All @@ -34,10 +34,10 @@ func NewNameDetail(snake string) (*NameDetail, error) {
return nameDetail, nil
}

func snakeToCamel(snake string, isUpper bool) (string,error) {
func snakeToCamel(snake string, isUpper bool) (string, error) {
var buf bytes.Buffer
isUnderBar := false
for i,c := range snake {
for i, c := range snake {
if (c < 'a' || 'z' < c) && c != '_' {
return "", fmt.Errorf("Invaid Non Small Case %s In %s", string(c), snake)
}
Expand Down
6 changes: 2 additions & 4 deletions statik/statik.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e7943a5

Please sign in to comment.