github.com/cyrilou242/gomobile-java@v0.0.0-20220215185836-09daef25a210/asset/asset_desktop.go (about)

     1  // Copyright 2014 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build (linux && !android) || (darwin && !arm && !arm64) || windows
     6  // +build linux,!android darwin,!arm,!arm64 windows
     7  
     8  package asset
     9  
    10  import (
    11  	"os"
    12  	"path/filepath"
    13  )
    14  
    15  func openAsset(name string) (File, error) {
    16  	if !filepath.IsAbs(name) {
    17  		name = filepath.Join("assets", name)
    18  	}
    19  	f, err := os.Open(name)
    20  	if err != nil {
    21  		return nil, err
    22  	}
    23  	return f, nil
    24  }