Original post

I can’t understand how (*ActivityService)(&c.common) is different from &ReplyService{client:c}

What is the difference between this expressions ? On playground it doesn’t show any error. I am familier with syntax of &ReplyService{client:c}.

package main

import (
        "fmt"
)
type Client struct{
        X int
        // https://github.com/google/-github/blob/ab35a4779b48b6089e8d3a80cc99c544695853eb/github/github.#L162
        common service // To reuse same struct instead of creating new for each service
        
        Activity *ActivityService
        Reply *ReplyService
}

type ActivityService service
type ReplyService service
type service struct{
        client *Client
}


func NewClient() *Client {
        c := &Client{X:5}
        c.common.client = c
// https://github.com/google/-github/blob/ab35a4779b48b6089e8d3a80cc99c544695853eb/github/github.#L260
// Copied this syntax from above link
        c.Activity = (*ActivityService)(&c.common)
        c.Reply = &ReplyService{client: c}
        
        return c
}
func main() {

        fmt.Println("Hello, playground")
}

playground link