Home / File/ text.go — gin Source File

text.go — gin Source File

Architecture documentation for text.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go ResponseRendering TemplateEngine 1 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  0d7062ba_5ddd_c2ed_4240_42b2dab1e9c2["text.go"]
  e8c9ceab_299a_1e0e_919f_ddb404deb199["fmt"]
  0d7062ba_5ddd_c2ed_4240_42b2dab1e9c2 --> e8c9ceab_299a_1e0e_919f_ddb404deb199
  style 0d7062ba_5ddd_c2ed_4240_42b2dab1e9c2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package render

import (
	"fmt"
	"net/http"

	"github.com/gin-gonic/gin/internal/bytesconv"
)

// String contains the given interface object slice and its format.
type String struct {
	Format string
	Data   []any
}

var plainContentType = []string{"text/plain; charset=utf-8"}

// Render (String) writes data with custom ContentType.
func (r String) Render(w http.ResponseWriter) error {
	return WriteString(w, r.Format, r.Data)
}

// WriteContentType (String) writes Plain ContentType.
func (r String) WriteContentType(w http.ResponseWriter) {
	writeContentType(w, plainContentType)
}

// WriteString writes data according to its format and write custom ContentType.
func WriteString(w http.ResponseWriter, format string, data []any) (err error) {
	writeContentType(w, plainContentType)
	if len(data) > 0 {
		_, err = fmt.Fprintf(w, format, data...)
		return
	}
	_, err = w.Write(bytesconv.StringToBytes(format))
	return
}

Subdomains

Functions

Types

Dependencies

  • fmt

Frequently Asked Questions

What does text.go do?
text.go is a source file in the gin codebase, written in go. It belongs to the ResponseRendering domain, TemplateEngine subdomain.
What functions are defined in text.go?
text.go defines 1 function(s): WriteString.
What does text.go depend on?
text.go imports 1 module(s): fmt.
Where is text.go in the architecture?
text.go is located at render/text.go (domain: ResponseRendering, subdomain: TemplateEngine, directory: render).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free