在Go中基于字符串选择正确的导入

Consider the following

import ( "library_a"
         "library_b"
         ...
         "library_z"

I want to be able to select the right library based on the letter.

So if I have z as input it will pick library_z.

What is a way to do this without requiring a massive switch statement?

If you want to use different libraries then you would have to import all of them and actually use them in your code.

From the docs:

It is illegal for a package to import itself, directly or indirectly, or to directly import a package without referring to any of its exported identifiers.

You will have to use a switch if you want to use different package implementations!