ioutil.WriteFile is deprecated, use os.WriteFile instead
372 if err != nil {
373 return err
374 }
375 return ioutil.WriteFile(outputPath+"/tables.go", c, 0644)376}
377
378func InsertPermissionOfTable(conn db.Connection, table string) {
ioutil.ReadFile is deprecated, use os.ReadFile instead
297 err error
298 )
299 if fileExist {
300 tablesContentByte, err = ioutil.ReadFile(outputPath + "/tables.go")301 if err != nil {
302 return err
303 }
ioutil.WriteFile is deprecated, use os.WriteFile instead
268 if err != nil {
269 return err
270 }
271 return ioutil.WriteFile(filepath.FromSlash(param.Output)+"/"+param.RowTable+".go", c, 0644)272}
273
274const (
ioutil.ReadAll is deprecated, use io.ReadAll instead
202 _ = res.Body.Close()
203 }()
204
205 body, err := ioutil.ReadAll(res.Body) 206
207 if err != nil {
208 return []map[string]interface{}{}, 0
ioutil.NopCloser is deprecated, use io.NopCloser instead
463 }
464
465 buf, _ := ioutil.ReadAll(content)
466 ctx.Response.Body = ioutil.NopCloser(bytes.NewBuffer(buf))467 return nil
468}
469
ioutil.ReadAll is deprecated, use io.ReadAll instead
462 ctx.SetContentType(filename)
463 }
464
465 buf, _ := ioutil.ReadAll(content)466 ctx.Response.Body = ioutil.NopCloser(bytes.NewBuffer(buf))
467 return nil
468}
ioutil.NopCloser is deprecated, use io.NopCloser instead
230
231// WriteString save the given body string into the response.
232func (ctx *Context) WriteString(body string) {
233 ctx.Response.Body = ioutil.NopCloser(strings.NewReader(body))234}
235
236// SetStatusCode save the given status code into the response.
ioutil.NopCloser is deprecated, use io.NopCloser instead
225func (ctx *Context) HTMLByte(code int, body []byte) {
226 ctx.SetContentType("text/html; charset=utf-8")
227 ctx.SetStatusCode(code)
228 ctx.Response.Body = ioutil.NopCloser(bytes.NewBuffer(body))229}
230
231// WriteString save the given body string into the response.
ioutil.NopCloser is deprecated, use io.NopCloser instead
204func (ctx *Context) Data(code int, contentType string, data []byte) {
205 ctx.Response.StatusCode = code
206 ctx.SetContentType(contentType)
207 ctx.Response.Body = ioutil.NopCloser(bytes.NewBuffer(data))208}
209
210// Redirect add redirect url to header.
ioutil.NopCloser is deprecated, use io.NopCloser instead
197 for key, head := range header {
198 ctx.AddHeader(key, head)
199 }
200 ctx.Response.Body = ioutil.NopCloser(bytes.NewBuffer(data))201}
202
203// Data writes some data into the body stream and updates the HTTP code.
ioutil.NopCloser is deprecated, use io.NopCloser instead
188 if err != nil {
189 panic(err)
190 }
191 ctx.Response.Body = ioutil.NopCloser(bytes.NewReader(BodyStr))192}
193
194// DataWithHeaders save the given status code, headers and body data into the response.
ioutil.NopCloser is deprecated, use io.NopCloser instead
176 for key, head := range header {
177 ctx.AddHeader(key, head)
178 }
179 ctx.Response.Body = ioutil.NopCloser(strings.NewReader(Body))180}
181
182// JSON serializes the given struct as JSON into the response body.
ioutil.ReadAll is deprecated, use io.ReadAll instead
158
159func (ctx *Context) MustBindJSON(data interface{}) {
160 if ctx.Request.Body != nil {
161 b, err := ioutil.ReadAll(ctx.Request.Body)162 if err != nil {
163 panic(err)
164 }
ioutil.ReadAll is deprecated, use io.ReadAll instead
147
148func (ctx *Context) BindJSON(data interface{}) error {
149 if ctx.Request.Body != nil {
150 b, err := ioutil.ReadAll(ctx.Request.Body)151 if err == nil {
152 return json.Unmarshal(b, data)
153 }
Description
io/ioutil
package, like most things with util in the name, has turned out to
be a poorly defined and complex to understand the collection of things.
In a series of a few changes, the entire ioutil package will become deprecated starting from Go 1.16.
Existing code using ioutil will continue to work; ioutil will consist of simple wrappers to new functions which reside in the io and os packages.
Bad practice
ioutil.ReadAll(r)
ioutil.ReadFile(filename)
ioutil.ReadDir(dirname)
// ...
Recommended
io.ReadAll(r)
os.ReadFile(filename)
os.ReadDir(dirname)
// ...