Type
필드의 모델 Product
가 있습니다. 이 같은
뭔가 : 나는 type
폼 PARAM이Go 제품의 종류를 확인하는 방법
type ProductType string
var (
PtRouteTransportation ProductType = "ProductRT"
PtOnDemandTransportation ProductType = "ProductDT"
PtExcursion ProductType = "ProductEX"
PtTicket ProductType = "ProductTK"
PtQuote ProductType = "ProductQT"
PtGood ProductType = "ProductGD"
)
type Product struct {
...
Type ProductType
...
}
기능 Create
에서 :
type := req.Form.Get("type")
질문 : 확인하는 방법 type
이 유효합니까?
가장 간단한 방법은 다음과 같습니다
if type != PtRouteTransportation && type != PtOnDemandTransportation && ...
하지만 Product
100 종류를 사용할 경우에 어떻게해야 무엇?
go
방법은? 대신 왜 개인 유형으로 유형 별칭을 사용하지 않는, 기본 유형으로 유형 별칭을 사용
'유형'의 유형은 무엇입니까? – Franchu