2
0
mirror of synced 2025-02-22 06:28:04 +00:00
mobile/asset/asset_desktop.go
David Crawshaw 8bb4ca139b asset: move app.Open to its own package
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>
2015-06-29 21:49:28 +00:00

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
}