Skip to main content

go_param_name

Function go_param_name 

Source
pub fn go_param_name(name: &str) -> String
Expand description

Convert a Rust snake_case parameter/variable name to Go lowerCamelCase with acronym uppercasing.

Go naming conventions require that acronyms in identifiers be fully uppercased. to_lower_camel_case alone converts base_urlbaseUrl, but Go wants baseURL. This function converts via PascalCase (which applies acronym uppercasing) then lowercases the first “word” (the initial run of uppercase letters treated as a unit) while preserving the case of subsequent words/acronyms:

  • base_urlBaseURLbaseURL
  • api_keyAPIKeyapiKey
  • user_idUserIDuserID
  • jsonJSONjson