title: How to minimize risk of SQL injection in downstream services in a golang service?
body: <p>I'm writing a semi-externally facing web service in golang that lets users query information about their accounts which are spread over several internal legacy services.</p>
  
  <p>My service passes user input strings onto multiple backend RESTful APIs which do MySQL lookups based on the strings to generate the results which are passed back to my service to give to the user.</p>
  
  <p>Historically, these legacy backend services have not been exposed to user input, so I'm not sure that they have the proper guards in place against SQL injection.</p>
  
  <p>Ordinarily I'd prevent SQL injection with <a href="https://stackoverflow.com/questions/26345318/how-can-i-prevent-sql-injection-attacks-in-go-while-using-database-sql">Prepared Statements</a> to keep the DB engine from treating user strings as parsable, but in this context I don't control the DB calls -- they're far downstream and it isn't practical to audit them all right now.</p>
  
  <p>What can I do in my golang code to sanitize the user input <em>as much as possible</em> to minimize the risk of an SQL injection slipping through? This is ultimately a stopgap measure until all the downstream DB calls can be audited for injection-safety.</p>
  
  <p>Edit: The user input can for all practical purposes be an arbitrary string, but it <em>shouldn't</em> ever be executable code. My service expects field values from the user, not code.</p>