rgbkrk / libvirt-go

[DEPRECATED] Go bindings for libvirt
https://github.com/libvirt/libvirt-go
MIT License
166 stars 50 forks source link

Organise constants into enums if possible #9

Closed alexzorin closed 10 years ago

alexzorin commented 10 years ago

As in #8 Must be backwards-compatible

alexzorin commented 10 years ago

@dorzheh the problem with

type VirDomainState int
const (
    VIR_DOMAIN_RUNNING VirDomainState = C.VIR_DOMAIN_RUNNING
    VIR_DOMAIN_SHUTOFF VirDomainState = C.VIR_DOMAIN_SHUTOFF
)

is that replacing the current consts (which are ints) is not backwards compatible:

./domain_test.go:170: invalid operation: state[0] != VIR_DOMAIN_RUNNING (mismatched types int and VirDomainState)
./domain_test.go:183: invalid operation: state[0] != VIR_DOMAIN_SHUTOFF (mismatched types int and VirDomainState)

Your way is correct if I had a chance to redo it but it looks like this will have to stay as it is for now

dorzheh commented 10 years ago

ok,