How to run a program with one command? [duplicate] - go

This question already has answers here:
How to compile Go program consisting of multiple files?
(7 answers)
How to compile a program in Go
(1 answer)
Go: How does go run file.go work
(4 answers)
Closed 9 months ago.
I have an app. There are many .go files, but also there are files with tests.
Of course, the command go run *.go don't work correct.
And now I should write every time something like that: go run fileName.go fileName.go fileName.go and so forth.
Is it possible to run programs with a shorter command ?
Thank You

Related

The meaning of ./... in make file is not clear [duplicate]

This question already has answers here:
What do three dots "./..." mean in Go command line invocations?
(2 answers)
What does the following argument in a terminal command mean: ./ [duplicate]
(1 answer)
Closed 6 months ago.
what is the meaning of ./... in make file.
Below are few example where it is used in the make file
https://github.com/cosmos/gaia/blob/main/Makefile#L102
https://github.com/strangelove-ventures/packet-forward-middleware/blob/main/Makefile#L111
... (ellipsis) is a wildcard used by go to represent all subdirectories (recursively).
You can see it documented in go help packages.
It is seen commonly in go get ./... to get the current directory's (.) packages and all its subdirectories (...) packages.

Ways to execute bash script without "./"? [duplicate]

This question already has answers here:
How do I run a shell script without using "sh" or "bash" commands?
(13 answers)
How to enable a system-wide function for users including sudo?
(2 answers)
Closed 3 years ago.
I have a bash script called climb.sh. When I execute it I write
./climb.sh 1
while inside the directory in which the script is located. However, I want to do the same thing wherever I am, and across all shell sessions by simply calling
climb 1
Also, climb.sh takes an numeric argument and calls "cd ../" that many times. In order for the program to work, it has to run alongside the current process, not within some child process.
How to achieve all this?
Thanks

why bash shell does not make any difference after executed? [duplicate]

This question already has answers here:
Global environment variables in a shell script
(7 answers)
Closed 5 years ago.
I'm working a small project which needs using OpenMPI to make "mpicc" work.
I made a file make_cmd:
#!/bin/bash
module load OpenMPI
However, after executing ./make_cmd, I was told:
mpicc: command not found
But if I just type on the command line: module load OpenMPI, then mpicc is working.
Why is that? Thanks!
See this answer on neighbouring site.
Because module is an alias/shell function and not a binary program, it's not necessarily available in the non-interactive sub-shell that is created when you run your script. You could probably run source make_cmd though, as that will just run the commands in your current interactive shell. You could ditch the #!/bin/bash line in that case.

Is there a way to run go test for only one file? [duplicate]

This question already has answers here:
Just run single test instead of the whole suite? [duplicate]
(6 answers)
Closed 10 months ago.
I checked documentation and help tutorial. Didn't find answer.
I just want to run a_test.go not all *_test.go.
Is this possible or how?
thanks a lot!
Command Documentation
Command go
Description of testing flags
The following flags are recognized by the 'go test' command and
control the execution of any test:
-run regexp
Run only those tests and examples matching the regular
expression.
To run the tests which satisfy the regex regular expression:
go test -run=regexp

Scheme and Build Pre-Action Script Output? [duplicate]

This question already has answers here:
How to display compiler output or custom build steps output when building with xcode?
(7 answers)
Closed 5 years ago.
I have a scheme in Xcode 4. I edited the scheme so that Build has a Pre-Action, and that action is a script.
The script is simple - it dumps pre-processor defines: cpp -dM < /dev/null.
Where do I find the output of the script?
add this line to pre-action script
pwd > ~/current_directory.txt
then check file current_directory.txt in your home directory

Resources