Skip to content

Instantly share code, notes, and snippets.

@palash25
Created May 19, 2019 17:28
Show Gist options
  • Select an option

  • Save palash25/db16be4f9edb79e4e4568bf02f76ceb8 to your computer and use it in GitHub Desktop.

Select an option

Save palash25/db16be4f9edb79e4e4568bf02f76ceb8 to your computer and use it in GitHub Desktop.
const (
USER_INDEX_VERSION = "1"
RESPONSE_INDEX_VERSION = "2"
ORGANIZATION_INDEX_VERSION = "1"
)
func index_and_type(typ string, version string, org_id string) (string, string) {
switch type {
case "user":
if version != "" {
return fmt.Printf("user_v%s", version), "user"
}
else {
return fmt.Printf("user_v%s", USER_INDEX_VERSION), "user"
}
case "org":
if version != "" {
return fmt.Printf("organization_v%s", version), "organization"
}
else {
return fmt.Printf("organization_v%s", ORGANIZATION_INDEX_VERSION), "organization"
}
case "response":
// Add org_id_digest = hashlib.md5(org_id.encode('utf-8')).hexdigest()
if version != "" {
return fmt.Printf("response_v%s", version), "response"
}
else {
return fmt.Printf("response_v%s",RESPONSE_INDEX_VERSION), "response"
}
default:
return nil, nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment