How I did Go abstract classes one time

submited by
Style Pass
2024-12-27 05:00:04

X__this can be any implementation of the root interface (which every child class will be) and then the parent class can call all child methods (which can be overridden) on that X__this pointer. I think that's cool. There are a few caveats though:

package main import ( "fmt" "os" "path/filepath" ) type path string type PlatformDirs interface { UserCacheDir() string UserCachePath() path isPlatformDirs() } type

package main import ( "fmt" "os" "path/filepath" ) type path string type PlatformDirs interface { UserCacheDir() string UserCachePath() path isPlatformDirs() } type

Leave a Comment