x/mobile/cmd/gomobile: allow digits-only basename for Android package name

Now package names for Android is generated based on the given package
path's base name, And the package name generation fails when the base
name consists of only digits (e.g. github.com/hajimehoshi/ebiten/examples/2048).

This CL fixes this problem by allowing only-number base name.

Fixes #24511

Change-Id: I6108c46823d0b2ee08869b306922f62351fb1510
Reviewed-on: https://go-review.googlesource.com/102576
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/cmd/gomobile/build_androidapp.go b/cmd/gomobile/build_androidapp.go
index d0d7955..06b2571 100644
--- a/cmd/gomobile/build_androidapp.go
+++ b/cmd/gomobile/build_androidapp.go
@@ -287,20 +287,15 @@
 // but not exactly same.
 func androidPkgName(name string) string {
 	var res []rune
-	for i, r := range name {
+	for _, r := range name {
 		switch {
-		case 'a' <= r && r <= 'z', 'A' <= r && r <= 'Z':
-			res = append(res, r)
-		case '0' <= r && r <= '9':
-			if i == 0 {
-				panic(fmt.Sprintf("package name %q is not a valid go package name", name))
-			}
+		case 'a' <= r && r <= 'z', 'A' <= r && r <= 'Z', '0' <= r && r <= '9':
 			res = append(res, r)
 		default:
 			res = append(res, '_')
 		}
 	}
-	if len(res) == 0 || res[0] == '_' {
+	if len(res) == 0 || res[0] == '_' || ('0' <= res[0] && res[0] <= '9') {
 		// Android does not seem to allow the package part starting with _.
 		res = append([]rune{'g', 'o'}, res...)
 	}
diff --git a/cmd/gomobile/build_test.go b/cmd/gomobile/build_test.go
index 5b4358d..f353f7b 100644
--- a/cmd/gomobile/build_test.go
+++ b/cmd/gomobile/build_test.go
@@ -54,6 +54,7 @@
 		{".-.", "go___"},
 		{"abstract", "abstract_"},
 		{"Abstract", "Abstract"},
+		{"12345", "go12345"},
 	}
 
 	for _, tc := range tests {