12345678910111213141516171819202122232425262728293031323334 |
- package sdk
- import (
- "fmt"
- "os"
- "notabug.org/Umnik/GoAndroidSDK/v2/components/misc"
- )
- func NewSDKFromPath(dirPath string) (*SDK, error) {
- if err := misc.TestDir(dirPath); err != nil {
- return nil, err
- } else {
- return &SDK{dirPath: dirPath}, nil
- }
- }
- func NewSDKFromEnv(env string) (*SDK, error) {
- return NewSDKFromPath(os.ExpandEnv(env))
- }
- func NewSDK() (*SDK, error) {
- environments := []string{"ANDROID_HOME", "ANDROID_SDK_ROOT"}
- for _, val := range environments {
- if key, ok := os.LookupEnv(val); ok {
- return NewSDKFromEnv(key)
- }
- }
- return nil, fmt.Errorf("following environments was checked: %q. They are not set", environments)
- }
|