I know there are no destructors in Go since technically there are no classes. As such, I use initClass
to perform the same functions as a constructor. However, is there any way to create something to mimic a destructor in the event of a termination, for the use of, say, closing files? Right now I just call defer deinitClass
, but this is rather hackish and I think a poor design. What would be the proper way?
question from:
https://stackoverflow.com/questions/32768243/go-destructors 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…