You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sendgrid.go
    path of file: ./repos/upspin/cloud/mail/sendgrid
    
    the code of the file until where you have to start completion: // Copyright 2016 The Upspin Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package sendgrid sends email using SendGrid.
package sendgrid 
    
func (s *sendgrid) Send(to, from, subject, text, html string) error {
	const op errors.Op = "cloud/mail/sendgrid.Send"
	if text == "" && html == "" {
		return errors.E(op, errors.Invalid, "text or html body must be provided")
	}
	msg := message{
		Personalizations: []personalizations{{
			To:      []addr{{Email: to}},
			Subject: subject,
		}},
		From: addr{Email: from},
	}
	// The order of Content must be: plain, html.
	if text != "" {
		msg.Content = append(msg.Content, content{
			Type:  "text/plain",
			Value: text,
		})
	}
	if html != "" {
		msg.Content = append(msg.Content, content{
			Type:  "text/html",
			Value: html,
		})
	}

	data, err := json.Marshal(&msg)
	if err != nil {
		return errors.E(op, errors.IO, err)
	}
	req, err := http.NewRequest("POST", apiSend, bytes.NewBuffer(data))
	if err != nil {
		return errors.E(op, errors.IO, err)
	}
	req.Header.Set("Authorization", "Bearer "+s.apiKey)
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return errors.E(op, errors.IO, err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusAccepted {
		errStr, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return errors.E(op, errors.IO, err)
		}
		return errors.E(op, errors.IO, string(errStr))
	}

	return nil
}