import ( "github.com/docker/machine/cli" "github.com/docker/machine/libmachine" ) func main() { c := cli.NewContext(nil, nil, nil) api := libmachine.NewClient(c.GlobalString("storage-path")) active, err := api.LoadActive() if err != nil { // handle error } // do something with active machine context }
import ( "fmt" "github.com/docker/machine/cli" ) func main() { c := cli.NewContext(nil, nil, nil) fmt.Println("Current machine context:", c.String("machine")) c.Set("machine", "new_context") fmt.Println("New machine context:", c.String("machine")) }This code example demonstrates how to switch between different machine contexts using the `Context` object. We create a new `Context` object and print out the current machine context using the `String` method. We then set the machine context to another context using the `Set` method and print out the new context.