如何在不破坏客户端代码的情况下拆分大型程序包?

Let's say I have a library package called foobar.

Over time it became big and heavy.

Fortunately it's separable, I managed to split its functionality into two separate packages foo and bar -- most clients will only need to use one or the other.

Since my library is already in use by many clients, for compatibility I still want to maintain a foobar package as a proxy to the current functionality found in both foo and bar.

How does one achieve this in Go ?

One way that comes to mind is to create aliases in foobar for each struct/function in foo and bar. So if foo defines F() and bar defines B(), I would have in foobar:

var (
  F = foo.F
  B = bar.B
)

But I am hoping for an easier/cleaner way.

Creating an alias package is the only way. But your attempt probably won't work: It works only for functions and variables and consts but not for types. For types you have to duplicate the type in foobar.

I wouldn't do this. Just have foobar around in version 1 and start anew with foo and bar (maybe directly in version 2).