wire/cmd/wire: rename from gowire (google/go-cloud#217)
@cflewis and @bradfitz were right: drop the "go". It's cleaner.
This commit is contained in:
14
README.md
14
README.md
@@ -11,10 +11,10 @@ initialization.
|
|||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|
||||||
Install `gowire` by running the following:
|
Install Wire by running:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
go get github.com/google/go-cloud/wire/cmd/gowire
|
go get github.com/google/go-cloud/wire/cmd/wire
|
||||||
```
|
```
|
||||||
|
|
||||||
## Basics
|
## Basics
|
||||||
@@ -156,19 +156,19 @@ used during code generation for that injector.
|
|||||||
Any non-injector declarations found in a file with injectors will be copied into
|
Any non-injector declarations found in a file with injectors will be copied into
|
||||||
the generated file.
|
the generated file.
|
||||||
|
|
||||||
You can generate the injector by invoking `gowire` in the package directory:
|
You can generate the injector by invoking Wire in the package directory:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
gowire
|
wire
|
||||||
```
|
```
|
||||||
|
|
||||||
Wire will produce an implementation of the injector in a file called
|
Wire will produce an implementation of the injector in a file called
|
||||||
`wire_gen.go` that looks something like this:
|
`wire_gen.go` that looks something like this:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// Code generated by gowire. DO NOT EDIT.
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
//go:generate gowire
|
//go:generate wire
|
||||||
//+build !wireinject
|
//+build !wireinject
|
||||||
|
|
||||||
package main
|
package main
|
||||||
@@ -314,7 +314,7 @@ func injectFoo() Foo {
|
|||||||
|
|
||||||
It's important to note that the expression will be copied to the injector's
|
It's important to note that the expression will be copied to the injector's
|
||||||
package; references to variables will be evaluated during the injector
|
package; references to variables will be evaluated during the injector
|
||||||
package's initialization. `gowire` will emit an error if the expression calls
|
package's initialization. Wire will emit an error if the expression calls
|
||||||
any functions or receives from any channels.
|
any functions or receives from any channels.
|
||||||
|
|
||||||
### Cleanup functions
|
### Cleanup functions
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
// gowire is a compile-time dependency injection tool.
|
// Wire is a compile-time dependency injection tool.
|
||||||
//
|
//
|
||||||
// For an overview, see https://github.com/google/go-cloud/blob/master/wire/README.md
|
// For an overview, see https://github.com/google/go-cloud/blob/master/wire/README.md
|
||||||
package main
|
package main
|
||||||
@@ -53,11 +53,11 @@ func main() {
|
|||||||
case len(os.Args) == 3 && os.Args[1] == "gen":
|
case len(os.Args) == 3 && os.Args[1] == "gen":
|
||||||
err = generate(os.Args[2])
|
err = generate(os.Args[2])
|
||||||
default:
|
default:
|
||||||
fmt.Fprintln(os.Stderr, "gowire: usage: gowire [gen] [PKG] | gowire show [...] | gowire check [...]")
|
fmt.Fprintln(os.Stderr, "usage: wire [gen] [PKG] | wire show [...] | wire check [...]")
|
||||||
os.Exit(64)
|
os.Exit(64)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "gowire:", err)
|
fmt.Fprintln(os.Stderr, "wire:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ func generate(pkg string) error {
|
|||||||
}
|
}
|
||||||
if len(out) == 0 {
|
if len(out) == 0 {
|
||||||
// No Wire directives, don't write anything.
|
// No Wire directives, don't write anything.
|
||||||
fmt.Fprintln(os.Stderr, "gowire: no injector found for", pkg)
|
fmt.Fprintln(os.Stderr, "wire: no injector found for", pkg)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
p := filepath.Join(pkgInfo.Dir, "wire_gen.go")
|
p := filepath.Join(pkgInfo.Dir, "wire_gen.go")
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
//+build wireinject
|
//+build wireinject
|
||||||
|
|
||||||
// All of the declarations are in one file.
|
// All of the declarations are in one file.
|
||||||
// gowire should copy non-injectors over, preserving imports.
|
// Wire should copy non-injectors over, preserving imports.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|||||||
@@ -158,8 +158,8 @@ func (g *gen) frame() []byte {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
buf.WriteString("// Code generated by gowire. DO NOT EDIT.\n\n")
|
buf.WriteString("// Code generated by Wire. DO NOT EDIT.\n\n")
|
||||||
buf.WriteString("//go:generate gowire\n")
|
buf.WriteString("//go:generate wire\n")
|
||||||
buf.WriteString("//+build !wireinject\n\n")
|
buf.WriteString("//+build !wireinject\n\n")
|
||||||
buf.WriteString("package ")
|
buf.WriteString("package ")
|
||||||
buf.WriteString(g.prog.Package(g.currPackage).Pkg.Name())
|
buf.WriteString(g.prog.Package(g.currPackage).Pkg.Name())
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func TestWire(t *testing.T) {
|
|||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
// Run gowire from a fake build context.
|
// Run Wire from a fake build context.
|
||||||
bctx := test.buildContext()
|
bctx := test.buildContext()
|
||||||
gen, errs := Generate(bctx, wd, test.pkg)
|
gen, errs := Generate(bctx, wd, test.pkg)
|
||||||
if len(gen) > 0 {
|
if len(gen) > 0 {
|
||||||
|
|||||||
2
wire.go
2
wire.go
@@ -36,7 +36,7 @@ func NewSet(...interface{}) ProviderSet {
|
|||||||
// panic(wire.Build(otherpkg.FooSet, myProviderFunc))
|
// panic(wire.Build(otherpkg.FooSet, myProviderFunc))
|
||||||
// }
|
// }
|
||||||
func Build(...interface{}) string {
|
func Build(...interface{}) string {
|
||||||
return "implementation not generated, run gowire"
|
return "implementation not generated, run wire"
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Binding maps an interface to a concrete type.
|
// A Binding maps an interface to a concrete type.
|
||||||
|
|||||||
Reference in New Issue
Block a user