aefix: Update code using taskqueue.QueueStats.
Also drop the suggestion to use sed from the README.
Anyone desiring automation should use aefix instead.
Change-Id: I296056ce27400372751783db88e1a2eab102be5a
diff --git a/README.md b/README.md
index 90e0036..1efd955 100644
--- a/README.md
+++ b/README.md
@@ -44,12 +44,6 @@
The import paths for App Engine packages are now fully qualified, based at `google.golang.org/appengine`.
You will need to update your code to use import paths starting with that; for instance,
code importing `appengine/datastore` will now need to import `google.golang.org/appengine/datastore`.
-You can do that manually, or by running this command to recursively update all Go source files in the current directory:
-(may require GNU sed)
-```
-sed -i '/"appengine/{s,"appengine,"google.golang.org/appengine,;s,appengine_,appengine/,}' \
- $(find . -name '*.go')
-```
### 3. Update code using deprecated, removed or modified APIs
diff --git a/cmd/aefix/ae.go b/cmd/aefix/ae.go
index 2449842..f310440 100644
--- a/cmd/aefix/ae.go
+++ b/cmd/aefix/ae.go
@@ -116,6 +116,11 @@
fixed = true
return
}
+ if isPkgDot(call.Fun, "taskqueue", "QueueStats") && len(call.Args) == 3 {
+ call.Args = call.Args[:2] // drop last arg
+ fixed = true
+ return
+ }
sel, ok := call.Fun.(*ast.SelectorExpr)
if !ok {
diff --git a/cmd/aefix/ae_test.go b/cmd/aefix/ae_test.go
index 33b99fe..e76c4c0 100644
--- a/cmd/aefix/ae_test.go
+++ b/cmd/aefix/ae_test.go
@@ -84,4 +84,33 @@
}
`,
},
+
+ // Less widely used API changes:
+ // - drop maxTasks arg to taskqueue.QueueStats
+ {
+ Name: "ae.2",
+ In: `package foo
+
+import (
+ "appengine"
+ "appengine/taskqueue"
+)
+
+func f(ctx appengine.Context) {
+ stats, err := taskqueue.QueueStats(ctx, []string{"one", "two"}, 0)
+}
+`,
+ Out: `package foo
+
+import (
+ "golang.org/x/net/context"
+ "google.golang.org/appengine"
+ "google.golang.org/appengine/taskqueue"
+)
+
+func f(ctx context.Context) {
+ stats, err := taskqueue.QueueStats(ctx, []string{"one", "two"})
+}
+`,
+ },
}