code: func (r *Repository) CreateTag(name string, hash plumbing.Hash, opts *CreateTagOptions) (*plumbing.Reference, error) {
  	rname := plumbing.ReferenceName(path.Join("refs", "tags", name))
  
  	_, err := r.Storer.Reference(rname)
  	switch err {
  	case nil:
  		// Tag exists, this is an error
  		return nil, ErrTagExists
  	case plumbing.ErrReferenceNotFound:
  		// Tag missing, available for creation, pass this
  	default:
  		// Some other error
  		return nil, err
  	}
  
  	var target plumbing.Hash
  	if opts != nil {
  		target, err = r.createTagObject(name, hash, opts)
  		if err != nil {
  			return nil, err
  		}
  	} else {
  		target = hash
  	}
  
  	ref := plumbing.NewHashReference(rname, target)
  	if err = r.Storer.SetReference(ref); err != nil {
  		return nil, err
  	}
  
  	return ref, nil
  }
docs: // CreateTag creates a tag. If opts is included, the tag is an annotated tag,
  // otherwise a lightweight tag is created.