|
1 | 1 | # interfaces [](https://godoc.org/github.com/rjeczalik/interfaces) [](https://travis-ci.org/rjeczalik/interfaces "linux_amd64") [](https://ci.appveyor.com/project/rjeczalik/interfaces "windows_amd64") |
2 | 2 | Code generation tools for Go's interfaces. |
3 | 3 |
|
| 4 | +### cmd/structer [](https://godoc.org/github.com/rjeczalik/interfaces/cmd/structer) |
| 5 | + |
| 6 | +Generates a struct for a formatted file. Currently supported formats are: |
| 7 | + |
| 8 | +- CSV |
| 9 | + |
| 10 | +*Usage* |
| 11 | + |
| 12 | +``` |
| 13 | +~ $ structer -help |
| 14 | +``` |
| 15 | +``` |
| 16 | +Usage of structer: |
| 17 | + -as string |
| 18 | + Generated struct name. (default "main.Struct") |
| 19 | + -f string |
| 20 | + Input file. (default "-") |
| 21 | + -o string |
| 22 | + Output file. (default "-") |
| 23 | + -tag string |
| 24 | + Name for a struct tag to add to each field. |
| 25 | + -type string |
| 26 | + Type of the input, overwrites inferred from file name. |
| 27 | +``` |
| 28 | + |
| 29 | +*Example* |
| 30 | + |
| 31 | +``` |
| 32 | +~ $ head -2 aws-billing.csv # first line is a CSV header, second - first line of values |
| 33 | +``` |
| 34 | +``` |
| 35 | +"InvoiceID","PayerAccountId","LinkedAccountId","RecordType","RecordId","ProductName","RateId","SubscriptionId","PricingPlanId","UsageType","Operation","AvailabilityZone","ReservedInstance","ItemDescription","UsageStartDate","UsageEndDate","UsageQuantity","BlendedRate","BlendedCost","UnBlendedRate","UnBlendedCost","ResourceId" |
| 36 | +"Estimated","54321","54321","LineItem","543212345","AWS CloudTrail","12345","12345","12345","USE1-FreeEventsRecorded","None","","N","0.0 per free event recorded in US East (N.Virginia) region","2016-01-01 00:00:00","2016-01-01 01:00:00","4105.00000000","0.0000000000","0.00000000","0.0000000000","0.00000000","" |
| 37 | +``` |
| 38 | +``` |
| 39 | +$ structer -f aws-billing.csv -tag json -as billing.Record |
| 40 | +``` |
| 41 | +``` |
| 42 | +// Created by structer; DO NOT EDIT |
| 43 | +
|
| 44 | +package billing |
| 45 | +
|
| 46 | +// Record is an struct generated from "aws-billing.csv" file. |
| 47 | +type Record struct { |
| 48 | + InvoiceID string `json:"invoiceID"` |
| 49 | + PayerAccountID int64 `json:"payerAccountID"` |
| 50 | + LinkedAccountID int64 `json:"linkedAccountID"` |
| 51 | + RecordType string `json:"recordType"` |
| 52 | + RecordID float64 `json:"recordID"` |
| 53 | + ProductName string `json:"productName"` |
| 54 | + RateID int64 `json:"rateID"` |
| 55 | + SubscriptionID int64 `json:"subscriptionID"` |
| 56 | + PricingPlanID int64 `json:"pricingPlanID"` |
| 57 | + UsageType string `json:"usageType"` |
| 58 | + Operation string `json:"operation"` |
| 59 | + AvailabilityZone string `json:"availabilityZone"` |
| 60 | + ReservedInstance string `json:"reservedInstance"` |
| 61 | + ItemDescription string `json:"itemDescription"` |
| 62 | + UsageStartDate string `json:"usageStartDate"` |
| 63 | + UsageEndDate string `json:"usageEndDate"` |
| 64 | + UsageQuantity float64 `json:"usageQuantity"` |
| 65 | + BlendedRate float64 `json:"blendedRate"` |
| 66 | + BlendedCost float64 `json:"blendedCost"` |
| 67 | + UnBlendedRate float64 `json:"unBlendedRate"` |
| 68 | + UnBlendedCost float64 `json:"unBlendedCost"` |
| 69 | + ResourceID string `json:"resourceID"` |
| 70 | +} |
| 71 | +``` |
| 72 | + |
4 | 73 | ### cmd/interfacer [](https://godoc.org/github.com/rjeczalik/interfaces/cmd/interfacer) |
5 | 74 |
|
6 | 75 | Generates an interface for a named type. |
|
0 commit comments