Shell Expansion (Command substitution) in Golang
问题 Go has the support for variable expansion , for example: os.ExpandEnv("test- ${USER} ")` >> "test-MyName" But is there a way of expanding executables , as the way the shell behaves? Something like os.ExpandExecutable("test- $(date +%H:%M) ") >> "test-18:20" I cannot find an equivalent method for this, is there an elegant way of doing this instead of manually extracting the placeholders out, executing and then replacing them? 回答1: There's no built in function for this, but you can write a