| 1 |
// Copyright 2018 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package server |
| 6 |
|
| 7 |
import ( |
| 8 |
"context" |
| 9 |
"errors" |
| 10 |
) |
| 11 |
|
| 12 |
type A struct { |
| 13 |
x int |
| 14 |
} |
| 15 |
|
| 16 |
func (a *A) AMethod(y int) *Server { |
| 17 |
return nil |
| 18 |
} |
| 19 |
|
| 20 |
// FooServer is a server that provides Foo services |
| 21 |
type FooServer Server |
| 22 |
|
| 23 |
func (f *FooServer) WriteEvents(ctx context.Context, x int) error { |
| 24 |
return errors.New("hey!") |
| 25 |
} |
| 26 |
|
| 27 |
type Server struct { |
| 28 |
FooServer *FooServer |
| 29 |
user string |
| 30 |
ctx context.Context |
| 31 |
} |
| 32 |
|
| 33 |
func New(sctx context.Context, u string) (*Server, error) { |
| 34 |
s := &Server{user: u, ctx: sctx} |
| 35 |
s.FooServer = (*FooServer)(s) |
| 36 |
return s, nil |
| 37 |
} |