github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/compiler/testdata/string.go (about) 1 package main 2 3 func someString() string { 4 return "foo" 5 } 6 7 func zeroLengthString() string { 8 return "" 9 } 10 11 func stringLen(s string) int { 12 return len(s) 13 } 14 15 func stringIndex(s string, index int) byte { 16 return s[index] 17 } 18 19 func stringCompareEqual(s1, s2 string) bool { 20 return s1 == s2 21 } 22 23 func stringCompareUnequal(s1, s2 string) bool { 24 return s1 != s2 25 } 26 27 func stringCompareLarger(s1, s2 string) bool { 28 return s1 > s2 29 } 30 31 func stringLookup(s string, x uint8) byte { 32 // Test that x is correctly extended to an uint before comparison. 33 return s[x] 34 }