How to create Go API to accept shell commands and give their output?

I am a beginner in Golang and I’m using os/exec package to read input from user and run simple shell commands (ls, pwd) inside go program.
But I’m unable to find ways to execute long commands as well return error code if command doesn’t run successfully.

Hello @jhaabhishek115,

Are you following any lab or course and got the problem?
You mind sharing a screenshot and explain your situation?

Thanks,
Trung.

I have completed the course and started building projects and encountered this issue.

Hello @jhaabhishek115,

Would you mind sharing the screenshot of the error?

Thanks,
Trung.