This does not break the dependency on the app package's AndroidContext for loading assets on android. A potential answer for gobind-based apps: add a SetAndroidContext method to app.Context. But I'll explore that separately after the long weekend. Change-Id: I812f899740e288c379eee7900f42d9d53926d4ce Reviewed-on: https://go-review.googlesource.com/11675 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
24 lines
449 B
Go
24 lines
449 B
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build linux,!android darwin,!arm,!arm64
|
|
|
|
package asset
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func openAsset(name string) (File, error) {
|
|
if !filepath.IsAbs(name) {
|
|
name = filepath.Join("assets", name)
|
|
}
|
|
f, err := os.Open(name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return f, nil
|
|
}
|