Skip to content

Commit

Permalink
use iota to unify the enums definition (#3305)
Browse files Browse the repository at this point in the history
  • Loading branch information
oldme-git authored Feb 6, 2024
1 parent 7201468 commit e1fa990
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
25 changes: 14 additions & 11 deletions database/gdb/gdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ const (
type queryType int

const (
queryTypeNormal queryType = 0
queryTypeCount queryType = 1
queryTypeValue queryType = 2
queryTypeNormal queryType = iota
queryTypeCount
queryTypeValue
)

type joinOperator string
Expand All @@ -400,14 +400,17 @@ const (
type InsertOption int

const (
InsertOptionDefault InsertOption = 0
InsertOptionReplace InsertOption = 1
InsertOptionSave InsertOption = 2
InsertOptionIgnore InsertOption = 3
InsertOperationInsert = "INSERT"
InsertOperationReplace = "REPLACE"
InsertOperationIgnore = "INSERT IGNORE"
InsertOnDuplicateKeyUpdate = "ON DUPLICATE KEY UPDATE"
InsertOptionDefault InsertOption = iota
InsertOptionReplace
InsertOptionSave
InsertOptionIgnore
)

const (
InsertOperationInsert = "INSERT"
InsertOperationReplace = "REPLACE"
InsertOperationIgnore = "INSERT IGNORE"
InsertOnDuplicateKeyUpdate = "ON DUPLICATE KEY UPDATE"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions net/ghttp/ghttp_request_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
)

const (
parseTypeRequest = 0
parseTypeQuery = 1
parseTypeForm = 2
parseTypeRequest = iota
parseTypeQuery
parseTypeForm
)

var (
Expand Down
12 changes: 8 additions & 4 deletions net/ghttp/ghttp_server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ import (
const (
defaultHttpAddr = ":80" // Default listening port for HTTP.
defaultHttpsAddr = ":443" // Default listening port for HTTPS.
UriTypeDefault = 0 // Method names to the URI converting type, which converts name to its lower case and joins the words using char '-'.
UriTypeFullName = 1 // Method names to the URI converting type, which does not convert to the method name.
UriTypeAllLower = 2 // Method names to the URI converting type, which converts name to its lower case.
UriTypeCamel = 3 // Method names to the URI converting type, which converts name to its camel case.

)

const (
UriTypeDefault = iota // Method names to the URI converting type, which converts name to its lower case and joins the words using char '-'.
UriTypeFullName // Method names to the URI converting type, which does not convert to the method name.
UriTypeAllLower // Method names to the URI converting type, which converts name to its lower case.
UriTypeCamel // Method names to the URI converting type, which converts name to its camel case.
)

// ServerConfig is the HTTP Server configuration manager.
Expand Down
5 changes: 3 additions & 2 deletions net/gtcp/gtcp_conn_pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
)

const (
pkgHeaderSizeDefault = 2 // Header size for simple package protocol.
pkgHeaderSizeMax = 4 // Max header size for simple package protocol.
_ = iota << 1
pkgHeaderSizeDefault // Header size for simple package protocol.
pkgHeaderSizeMax // Max header size for simple package protocol.
)

// PkgOption is package option for simple protocol.
Expand Down
9 changes: 5 additions & 4 deletions net/gtcp/gtcp_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ type PoolConn struct {
status int // Status of current connection, which is used to mark this connection usable or not.
}

const defaultPoolExpire = 10 * time.Second // Default TTL for connection in the pool.

const (
defaultPoolExpire = 10 * time.Second // Default TTL for connection in the pool.
connStatusUnknown = 0 // Means it is unknown it's connective or not.
connStatusActive = 1 // Means it is now connective.
connStatusError = 2 // Means it should be closed and removed from pool.
connStatusUnknown = iota // Means it is unknown it's connective or not.
connStatusActive // Means it is now connective.
connStatusError // Means it should be closed and removed from pool.
)

var (
Expand Down

0 comments on commit e1fa990

Please sign in to comment.