func (c *Client) CreateDB(db string) error {
	u := *c.url
	q := u.Query()
	q.Del("db")
	u.Path = "/query"
	u.RawQuery = q.Encode()
	r, err := c.http.Post(u.String(), "application/x-www-form-urlencoded", strings.NewReader(
		fmt.Sprintf("q=CREATE DATABASE %q", db),
	))
	if err != nil {
		return err
	}
	return readResponse(r)
}
CreateDB creates a database named db in the InfluxDB server that the client
was configured to send metrics to.
package influxdb
import (
	"bytes"
	"context"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"strings"
	"sync"
	"time"
	"github.com/segmentio/objconv/json"
	"github.com/segmentio/stats/v4"
)
const (
	DefaultAddress = "localhost:8086"
	DefaultDatabase = "stats"
	DefaultBufferSize = 2 * 1024 * 1024  
	DefaultTimeout = 5 * time.Second
)
type ClientConfig struct {
	Address string
	Database string
	BufferSize int
	Timeout time.Duration
	Transport http.RoundTripper
}
type Client struct {
	serializer
	buffer stats.Buffer
}
func NewClient(addr string) *Client {
	return NewClientWith(ClientConfig{
		Address: addr,
	})
}
func NewClientWith(config ClientConfig) *Client {
	if len(config.Address) == 0 {
		config.Address = DefaultAddress
	}
	if len(config.Database) == 0 {
		config.Database = DefaultDatabase
	}
	if config.BufferSize == 0 {
		config.BufferSize = DefaultBufferSize
	}
	if config.Timeout == 0 {
		config.Timeout = DefaultTimeout
	}
	c := &Client{
		serializer: serializer{
			url:  makeURL(config.Address, config.Database),
			done: make(chan struct{}),
			http: http.Client{
				Timeout:   config.Timeout,
				Transport: config.Transport,
			},
		},
	}
	c.buffer.BufferSize = config.BufferSize
	c.buffer.Serializer = &c.serializer
	return c
}