It has been a long time since I programmed in C ++, but I know that in C ++ classes are organized into .h and .cpp files. Many other languages also benefit from dividing code into logical groupings in a directory structure to improve organization.
Well, I'm trying to learn how to go now, and I read the article Go for C ++ Programmers when I came across interfaces. The article explains that interfaces in Go essentially replace classes and show how to set them up pretty well.
What I'm trying to understand is how do I organize the interface into files? For example, should the interface be in one file and the implementation in another?
myInterface.go
type myInterface interface { get() int set(i int) }
myImplementation.go
type myType struct { i int } func (p *myType) set(i int) { p.i = i } func (p *myType) get() int { return p.i }
, , ( , , ), ? , , Go, !
. , , , , . C co. , , , "" (). Go , , , ( ).
- . , . , , , (, + , , , , Java ++). ; Go, C.
Go ++ C. . Go . ++. ++, Go For ++ Programmers.
Go. . Go, , .
Go - , .
time , Go. , ? , , , , , ?
time
Go , C , ++. ( C) Go, , . Go time . , , Go .
" ", , , . . , Go, , Go json.
json
Go . . , . .
Go . , , , , . . , Go .
Go? , , .