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
//the idea is taken from https://gist.github.com/bosgood/d9687f5d64c0f4038bc19c478d51fa64 | |
// but that code throw exception and does not compile | |
// I just refined that and fix the problem and convert it to Int version | |
// same can be done for other nullable types | |
// LeadItem struct | |
type LeadItem struct { | |
CustomerId sql.NullInt64 | |
} |
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
func strStr(haystack string, needle string) int { | |
if len(haystack) < len(needle) { | |
return -1 | |
} | |
needleBytes := needle[0:] | |
for i := 0; i < len(haystack); i++ { | |
if haystack[i:i+len(needle)] == needleBytes { | |
return i | |
} |