awsprofile is library of parse to ~/.aws/credentials and ~/.aws/config .
awsProfile := awsprofile.New() // Parse AWS_SHARED_CREDENTIALS_FILE and AWS_CONFIG_FILE if err := awsProfile.Parse(); err != nil { log.Fatal(err) } // Get profile names profiles, err := awsProfile.ProfileNames() if err != nil { log.Fatal(err) } fmt.Println(profiles) // Output: [default foo bar] // Get Configs configs, err := awsProfile.GetConfigs() if err != nil { log.Fatal(err) } // Get RoleArn roleArn, err := configs.GetRoleArn("bar") if err != nil { log.Fatal(err) } fmt.Println(roleArn) // Output: arn:aws:iam::xxxxxxxxxxxx:role/bar