github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/utilities/common/compiler/helpers.go (about) 1 package compiler 2 3 import ( 4 "bytes" 5 "io/ioutil" 6 "regexp" 7 ) 8 9 var versionRegexp = regexp.MustCompile(`([0-9]+)\.([0-9]+)\.([0-9]+)`) 10 11 type Contract struct { 12 Code string `json:"code"` 13 RuntimeCode string `json:"runtime-code"` 14 Info ContractInfo `json:"info"` 15 Hashes map[string]string `json:"hashes"` 16 } 17 18 type ContractInfo struct { 19 Source string `json:"source"` 20 Language string `json:"language"` 21 LanguageVersion string `json:"languageVersion"` 22 CompilerVersion string `json:"compilerVersion"` 23 CompilerOptions string `json:"compilerOptions"` 24 SrcMap interface{} `json:"srcMap"` 25 SrcMapRuntime string `json:"srcMapRuntime"` 26 AbiDefinition interface{} `json:"abiDefinition"` 27 UserDoc interface{} `json:"userDoc"` 28 DeveloperDoc interface{} `json:"developerDoc"` 29 Metadata string `json:"metadata"` 30 } 31 32 func slurpFiles(files []string) (string, error) { 33 var concat bytes.Buffer 34 for _, file := range files { 35 content, err := ioutil.ReadFile(file) 36 if err != nil { 37 return "", err 38 } 39 concat.Write(content) 40 } 41 return concat.String(), nil 42 }