yaml unmarshalling works

This commit is contained in:
Wyatt Miller 2019-08-13 11:01:26 -04:00
parent d315337e8f
commit 3c6953de6b
3 changed files with 30 additions and 5 deletions

View File

@ -1,12 +1,31 @@
package main
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
type Configuration struct {
Username string
Password string
Port int
Port string
Hosts []string
}
func initializeConfig() {
func initializeConfig(filename string) Configuration {
var config Configuration
source, err := ioutil.ReadFile(filename)
if err != nil {
panic(err)
}
err = yaml.Unmarshal(source, &config)
if err != nil {
panic(err)
}
return config
}

View File

@ -3,5 +3,11 @@ package main
import "fmt"
func main() {
fmt.Println("Hello!")
//fmt.Println("Hello!")
//var config Configuration
config := initializeConfig("config.yaml")
fmt.Println(config.Username)
}

4
ssh.go
View File

@ -1,6 +1,6 @@
package main
type sshConnection struct {
Username string
Password []string
Username Configuration
Password Configuration
}