What does the `...` mean in go get - go

I wanted to install gb
The installation steps says to execute the command:
go get github.com/constabulary/gb/...
What does the ... mean in this case?

The ... (ellipsis) tells go get to also fetch the package's subpackages/dependencies.
From go help packages:
An import path is a pattern if it includes one or more "..."
wildcards, each of which can match any string, including the empty
string and strings containing slashes. Such a pattern expands to all
package directories found in the GOPATH trees with names matching the
patterns. As a special case, x/... matches x as well as x's
subdirectories. For example, net/... expands to net and packages in
its subdirectories.
For an example of how you'd use it, check out this answer.

Related

Shell pattern matching - 2 files type, 1 exempt file type

I'm trying to find a shell pattern match that will match both...
/x1234001a.20_ and /x123001a.20.ext
but not
/x123001a.20.ext.A or /x123001a.20.A
What I have tried...
????????.??[_.]*[!A] - finds only .ext file
????????.??[_.]*[^A] - does not find either
????????.??[_.]*[ ext] - does not find either
????????.??[_.]* - finds both, but also finds .A files
It needs to be just the path that is capable of matching, no extra commands, no extglob shell option, and no regex
Thanks ahead of time!
Found my own answer!
????????.??*[!A]

golang gofmt package rewrite wildcard

I'm trying to do a gofmt rewrite of all packages that start with a certain prefix. Something like:
gofmt -r 'github.com/some/path/<wildcard> -> someotherrepo.com/some/path/<wildcard>'
Obviously wildcard isn't valid syntax, just showing the concept. I've tried with a single lowercase character, but that doesn't work here.
Is it possible to do what I'm trying with gofmt?
This is what the gofmt command page says
Given a file, it operates on that file; given a directory, it operates on all .go files
in that directory, recursively
https://golang.org/cmd/gofmt/

why doesn't *.abc match a file named .abc?

I thought I understood wildcards, till this happened to me. Essentially, I'm looking for a wild card pattern that would return all files that are not named .gitignore. I came up with this, which seems to work for all cases I could conjure:
ls *[!{gitignore}]
To really validate if this works, I thought I'd negate the expression and see if it returns the file named .gitignore (actually any file that ended with gitignore; so 1.gitignore should also be returned). To that effect, I thought the negated expression would be:
ls *[{gitignore}]
However, this expression doesn't return a files named .gitignore (although it returns a file named 1.gitignore).
Essentially, my question, after simplification, boils down to:
Why doesn't *.abc match a file that is named .abc
I think I can take it from there.
PS:
I am working on Mac OSX Lion (10.7.4)
I wanted to add a clause to .gitignore such that I would ignore every file, except .gitignore in a given folder. So I ended up adding * in the .gitignore file. Result was, git ended up ignoring .gitignore :)
From the numerous searches I've made on google - Use the asterisk character (*) to represent zero or more characters.
I assume you're using Bash. From the Bash manual:
When a pattern is used for filename expansion, the character ‘.’ at the start of a filename or immediately following a slash must be matched explicitly, unless the shell option dotglob is set.
.gitignore patterns, however, are treated differently:
Otherwise, git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname.
According to the fnmatch(3) docs, a leading dot has to be explicitly matched only if the FNM_PERIOD flag is set, so *gitignore as a gitignore pattern would match .gitignore.
There is an easier way to accomplish this, though. To have .gitignore ignore everything except .gitignore:
*
!.gitignore
If you want to ignore everything except the gitignore file, use this as the file:
*
!.gitignore
Lines starting with an exclamation point are interpreted as exceptions.

Linux shell list file what's the difference bewteen tmp/**/* and tmp/*

I encounter one problem about the file system in the shell.
what's difference between tmp/**/* and tmp/*?
I make the experiment in my system,
have this directory dir2
dir2
-->dir1
-->xx2
-->ff.txt
and I run ls dir2/*:
dir2/ff.txt
dir2/dir1:
xx2
then I run ls dir2/**/*:
dir2/dir1/xx2
So it means the ** is to ignore this directory(like ignore the dir1),
Can some one help me ?
I think there's a formatting issue in the question test, but I'll answer based on the question title and examples.
There shouldn't be any difference between a single and double asterisk at any single level of the path. Either expression matches any name, except for hidden ones which start with a dot (this can be changed by shell options). So:
tmp/**/* (equivalent to tmp/*/*) is expanded to all names which are nested two levels deep in tmp. The first asterisk expands only to directories and not files at the first level because it's followed by a slash.
tmp/* expands to anything nested one level deep inside tmp.
To this comes the fact that ls will list contents of directory if a directory is given on its command line. This can be overridden by adding -d option to ls.

What does two asterisks together in file path mean?

What does the following file path mean?
$(Services_Jobs_Drop_Path)\**\*.config
The variable just holds some path, nothing interesting. I'm a lot more concerned, what the hell the ** mean.
Any ideas?
P.S. The following path is used in msbuild scripts, if it helps.
\**\ This pattern is often used in Copy Task for recursive folder tree traversal. Basically it means that all files with extension config would be processed from the all subdirectories of $(Services_Jobs_Drop_Path) path.
MSDN, Using Wildcards to Specify Items:
You can use the **, *, and ? wildcard characters to specify a group of
files as inputs for a build instead of listing each file separately.
The ? wildcard character matches a single character.
The * wildcard character matches zero or more characters.
The ** wildcard character sequence matches a partial path.
MSDN, Specifying Inputs with Wildcards
To include all .jpg files in the Images directory and subdirectories
Use the following Include attribute:
Include="Images\**\*.jpg"

Resources