|
|
|
|
|
by ngalaiko
1467 days ago
|
|
another person who can’t get over his java stockholm syndrome in three (!) years one particular thing that tells that is the attitude to interfaces: while in java (and most languages) interfaces are used to tell which contracts a class implements, in go it’s reversed. you must declare interfaces to _require_ certain contracts, for arguments in your functions for example: type interface Operator {
Operate(int, int) int
} func IntOparation(a, b int, op Operator) int {
return op.Operate(a, b)
} this is a major difference highlighting the ownership boundaries:
* when I write a package and rely on a 3rd party contract, instead of referencing it and adhering to it, I will copy-paste parts that I need to my package and be independent |
|