Skip to content
This repository has been archived by the owner on Mar 22, 2020. It is now read-only.

Commit

Permalink
Merge pull request #7 from prysmaticlabs/fixedLengths
Browse files Browse the repository at this point in the history
Add fixed length Byte Arrays for Hex Encoded Strings
  • Loading branch information
prestonvanloon authored Jun 17, 2019
2 parents dbbcb05 + 2ce7993 commit cc20b0e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions yaml-to-go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,14 @@ export function yamlToGo(input: string, typename = "AutoGenerated", flatten = tr

switch (typeof val) {
case "string":
let newSlice = val.slice(2,),
newlen = newSlice.length/2,
strSlice = newlen.toString();

if (/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(val))
return "time.Time";
else if (val.startsWith('0x'))
return "["+strSlice+"]byte";
else return "string";
case "number":
if (val % 1 === 0) {
Expand Down

0 comments on commit cc20b0e

Please sign in to comment.