Beispiel #1
0
// NewEnchant creates a new Enchant instance for access
// to the rest of the Enchant API.
//
// The returned value is an Enchant struct.
//
// Example usage:
//
// 		enchant, err := enchant.NewEnchant()
// 		if err != nil {
// 			panic("Enchant error: " + err.Error())
// 		}
// 		defer enchant.Free()
//      fmt.Println(enchant.DictExists("zh"))
//
// Because the Enchant package is a binding to Enchant C library, memory
// allocated by the NewEnchant() call has to be disposed explicitly.
// This is why the above example contains a deferred call to Free().
func NewEnchant() (e *Enchant, err error) {
	broker := C.enchant_broker_init()
	e = &Enchant{broker, nil}
	// we don't return errors at the moment, but we might in the future
	return e, nil
}
Beispiel #2
0
// NewEnchant makes a new Enchant struct
func NewEnchant() (*Enchant, error) {
	broker := C.enchant_broker_init()
	// check for a broker error here
	return &Enchant{broker, nil}, nil
}