func (p *Point) String() string {
	return p.pt.String()
}
String returns a line-protocol string of the Point.
package client  
import (
	"bytes"
	"compress/gzip"
	"crypto/tls"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"mime"
	"net/http"
	"net/url"
	"path"
	"strconv"
	"strings"
	"time"
	"github.com/influxdata/influxdb1-client/models"
)
type ContentEncoding string
const (
	DefaultEncoding ContentEncoding = ""
	GzipEncoding    ContentEncoding = "gzip"
)
type HTTPConfig struct {
	Addr string
	Username string
	Password string
	UserAgent string
	Timeout time.Duration
	InsecureSkipVerify bool
	TLSConfig *tls.Config
	Proxy func(req *http.Request) (*url.URL, error)
	WriteEncoding ContentEncoding
}
type BatchPointsConfig struct {
	Precision string
	Database string
	RetentionPolicy string
	WriteConsistency string
}
type Client interface {
	Ping(timeout time.Duration) (time.Duration, string, error)
	Write(bp BatchPoints) error
	Query(q Query) (*Response, error)
	QueryAsChunk(q Query) (*ChunkedResponse, error)
	Close() error
}
func NewHTTPClient(conf HTTPConfig) (Client, error) {
	if conf.UserAgent == "" {
		conf.UserAgent = "InfluxDBClient"
	}
	u, err := url.Parse(conf.Addr)
	if err != nil {
		return nil, err
	} else if u.Scheme != "http" && u.Scheme != "https" {
		m := fmt.Sprintf("Unsupported protocol scheme: %s, your address"+
			" must start with http:// or https://", u.Scheme)
		return nil, errors.New(m)
	}
	switch conf.WriteEncoding {
	case DefaultEncoding, GzipEncoding:
	default:
		return nil, fmt.Errorf("unsupported encoding %s", conf.WriteEncoding)
	}
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: conf.InsecureSkipVerify,
		},
		Proxy: conf.Proxy,
	}
	if conf.TLSConfig != nil {
		tr.TLSClientConfig = conf.TLSConfig
	}
	return &client{
		url:       *u,
		username:  conf.Username,
		password:  conf.Password,
		useragent: conf.UserAgent,
		httpClient: &http.Client{
			Timeout:   conf.Timeout,
			Transport: tr,
		},
		transport: tr,
		encoding:  conf.WriteEncoding,
	}, nil
}
func (c *client) Ping(timeout time.Duration) (time.Duration, string, error) {
	now := time.Now()
	u := c.url
	u.Path = path.Join(u.Path, "ping")
	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return 0, "", err
	}
	req.Header.Set("User-Agent", c.useragent)
	if c.username != "" {
		req.SetBasicAuth(c.username, c.password)
	}
	if timeout > 0 {
		params := req.URL.Query()
		params.Set("wait_for_leader", fmt.Sprintf("%.0fs", timeout.Seconds()))
		req.URL.RawQuery = params.Encode()
	}
	resp, err := c.httpClient.Do(req)
	if err != nil {
		return 0, "", err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return 0, "", err
	}
	if resp.StatusCode != http.StatusNoContent {
		var err = errors.New(string(body))
		return 0, "", err
	}
	version := resp.Header.Get("X-Influxdb-Version")
	return time.Since(now), version, nil
}
func (c *client) Close() error {
	c.transport.CloseIdleConnections()
	return nil
}
type client struct {
	url        url.URL
	username   string
	password   string
	useragent  string
	httpClient *http.Client
	transport  *http.Transport
	encoding   ContentEncoding
}
type BatchPoints interface {
	AddPoint(p *Point)
	AddPoints(ps []*Point)
	Points() []*Point
	Precision() string
	SetPrecision(s string) error
	Database() string
	SetDatabase(s string)
	WriteConsistency() string
	SetWriteConsistency(s string)
	RetentionPolicy() string
	SetRetentionPolicy(s string)
}
func NewBatchPoints(conf BatchPointsConfig) (BatchPoints, error) {
	if conf.Precision == "" {
		conf.Precision = "ns"
	}
	if _, err := time.ParseDuration("1" + conf.Precision); err != nil {
		return nil, err
	}
	bp := &batchpoints{
		database:         conf.Database,
		precision:        conf.Precision,
		retentionPolicy:  conf.RetentionPolicy,
		writeConsistency: conf.WriteConsistency,
	}
	return bp, nil
}
type batchpoints struct {
	points           []*Point
	database         string
	precision        string
	retentionPolicy  string
	writeConsistency string
}
func (bp *batchpoints) AddPoint(p *Point) {
	bp.points = append(bp.points, p)
}
func (bp *batchpoints) AddPoints(ps []*Point) {
	bp.points = append(bp.points, ps...)
}
func (bp *batchpoints) Points() []*Point {
	return bp.points
}
func (bp *batchpoints) Precision() string {
	return bp.precision
}
func (bp *batchpoints) Database() string {
	return bp.database
}
func (bp *batchpoints) WriteConsistency() string {
	return bp.writeConsistency
}
func (bp *batchpoints) RetentionPolicy() string {
	return bp.retentionPolicy
}
func (bp *batchpoints) SetPrecision(p string) error {
	if _, err := time.ParseDuration("1" + p); err != nil {
		return err
	}
	bp.precision = p
	return nil
}
func (bp *batchpoints) SetDatabase(db string) {
	bp.database = db
}
func (bp *batchpoints) SetWriteConsistency(wc string) {
	bp.writeConsistency = wc
}
func (bp *batchpoints) SetRetentionPolicy(rp string) {
	bp.retentionPolicy = rp
}
type Point struct {
	pt models.Point
}
func NewPoint(
	name string,
	tags map[string]string,
	fields map[string]interface{},
	t ...time.Time,
) (*Point, error) {
	var T time.Time
	if len(t) > 0 {
		T = t[0]
	}
	pt, err := models.NewPoint(name, models.NewTags(tags), fields, T)
	if err != nil {
		return nil, err
	}
	return &Point{
		pt: pt,
	}, nil
}