我想问一下怎么使用GO实现这些方法?

a984120978 · · 1151 次点击
class File: name: str context: str file: open def __init__(self, name): self.name = name def open(self): self.file = open(self.name) def read(self): return self.file.read() def write(self, text): self.file.write(text) def close(self): self.file.close() def __del__(self): self.file.close()
#1
更多评论
package main type F interface { read() string write() string open() close() } type f struct { name string err error } func main() { }
#2
到这里就不会了
#3