text.go
This file
The walk stopped after 200 commits: lines older than cf32d2d point at it.
chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d
lines 1–41why, one step back1// Copyright 2014 Manu Martinez-Almeida. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package render67import (8 "fmt"9 "net/http"1011 "github.com/gin-gonic/gin/internal/bytesconv"12)1314// String contains the given interface object slice and its format.15type String struct {16 Format string17 Data []any18}1920var plainContentType = []string{"text/plain; charset=utf-8"}2122// Render (String) writes data with custom ContentType.23func (r String) Render(w http.ResponseWriter) error {24 return WriteString(w, r.Format, r.Data)25}2627// WriteContentType (String) writes Plain ContentType.28func (r String) WriteContentType(w http.ResponseWriter) {29 writeContentType(w, plainContentType)30}3132// WriteString writes data according to its format and write custom ContentType.33func WriteString(w http.ResponseWriter, format string, data []any) (err error) {34 writeContentType(w, plainContentType)35 if len(data) > 0 {36 _, err = fmt.Fprintf(w, format, data...)37 return38 }39 _, err = w.Write(bytesconv.StringToBytes(format))40 return41}