import ( "context" "github.com/mattermost/platform/api" ) func main() { mmAPI := api.NewClient("https://my.mattermost.server.com", "my_access_token") ctx := context.Background() ctx = context.WithValue(ctx, api.ContextUser, "my_username") ctx = context.WithValue(ctx, api.ContextChannel, "my_channel_id") post, resp := mmAPI.CreatePostWithContext(ctx, &api.Post{ ChannelId: "my_channel_id", Message: "Hello, World!", }) if resp.Error != nil { panic(resp.Error) } fmt.Printf("Created post: %v\n", post) }In this example, we create a new Mattermost API client and define a context with user and channel values. We then use the context to create a new post in the specified channel with the specified message. This ensures that the post is created with the correct user and in the correct channel.