import ( "github.com/docker/machine/libmachine" ) func main() { hostName := "my-docker-host" storePath := "/path/to/machine/store" // Create a new Machine Client client := libmachine.NewClient(storePath) // Load an existing machine machine, err := client.Load(hostName) if err != nil { // Handle error } // Use the machine // ... }
import ( "github.com/docker/machine/libmachine" ) func main() { hostName := "my-docker-host" storePath := "/path/to/machine/store" // Create a new Machine Client client := libmachine.NewClient(storePath) // Check if a machine exists exists, err := client.Exists(hostName) if err != nil { // Handle error } if exists { // Machine exists // ... } else { // Machine does not exist // ... } }In this example, we are using the Exists API to check if a machine with the given hostName exists in the store. If the machine exists, the exists variable is set to true, otherwise it is set to false.