Created
September 15, 2015 20:22
-
-
Save diverted247/5ca30db3344b1a41553f to your computer and use it in GitHub Desktop.
Dynamic model assignment from Struct in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Check struct { | |
StyleId string `json:"styleId" binding:"required"` | |
ProductCode string `json:"productCode" binding:"required"` | |
Overlay bool `json:"overlay"` | |
Font string `json:"font"` | |
OwnerText []string `json:"ownerText" binding:"required"` | |
BankText []string `json:"bankText" binding:"required"` | |
NumberingRouting string `json:"numberingRouting" binding:"required"` | |
NumberingAccount string `json:"numberingAccount" binding:"required"` | |
NumberingStart string `json:"numberingStart" binding:"required"` | |
GraphicsBackground string `json:"graphicsBackground"` | |
GraphicsExpression string `json:"graphicsExpression"` | |
GraphicsPridemark string `json:"graphicsPridemark"` | |
GraphicsLogo string `json:"graphicsLogo"` | |
SignatureExtraLines int `json:"signatureExtraLines"` | |
SignatureOverText []string `json:"signatureOverText"` | |
} | |
var model []string | |
if product.LayoutItems[v].Model == "ownerText" { | |
model = check.OwnerText | |
}else if product.LayoutItems[v].Model == "bankText" { | |
model = check.BankText | |
}else if product.LayoutItems[v].Model == "signatureOverText" { | |
model = check.SignatureOverText | |
} | |
for id , element := range model { | |
ft.DrawString( element , freetype.Pt( product.LayoutItems[v].X , product.LayoutItems[v].Y + id * product.Global.LineHeight ) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment