From 29253f4d513f1d3fe549db39a8daa311492138b3 Mon Sep 17 00:00:00 2001 From: apocelipes Date: Mon, 31 Jul 2023 19:40:37 +0000 Subject: [PATCH] os/exec: Use the built-in function min instead of minInt The built-in function `min` has been implemented and can now be used to replace some manually written `minType` helper functions. Change-Id: Ie8ffc7881c8652ece752751214f1242bf76a6e7e GitHub-Last-Rev: 5db344f13142c78f437571e3a1cdc0b02c0589cb GitHub-Pull-Request: golang/go#60866 Reviewed-on: https://go-review.googlesource.com/c/go/+/504315 Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: David Chase Reviewed-by: qiulaidongfeng <2645477756@qq.com> --- src/os/exec/exec.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index a23d1c4a2d..2881345fb3 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -1096,7 +1096,7 @@ func (w *prefixSuffixSaver) Write(p []byte) (n int, err error) { // grow larger than w.N. It returns the un-appended suffix of p. func (w *prefixSuffixSaver) fill(dst *[]byte, p []byte) (pRemain []byte) { if remain := w.N - len(*dst); remain > 0 { - add := minInt(len(p), remain) + add := min(len(p), remain) *dst = append(*dst, p[:add]...) p = p[add:] } @@ -1121,13 +1121,6 @@ func (w *prefixSuffixSaver) Bytes() []byte { return buf.Bytes() } -func minInt(a, b int) int { - if a < b { - return a - } - return b -} - // environ returns a best-effort copy of the environment in which the command // would be run as it is currently configured. If an error occurs in computing // the environment, it is returned alongside the best-effort copy. -- 2.48.1