Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
sliceopt.go33 linesDownload Raw Back to test
1// errorcheck -0 -d=append,slice2 3// Copyright 2015 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7// Check optimization results for append and slicing.8 9package main10 11func a1(x []int, y int) []int {12	x = append(x, y) // ERROR "append: len-only update \(in local slice\)$"13	return x14}15 16func a2(x []int, y int) []int {17	return append(x, y)18}19 20func a3(x *[]int, y int) {21	*x = append(*x, y) // ERROR "append: len-only update$"22}23 24func s1(x **[]int, xs **string, i, j int) {25	var z []int26	z = (**x)[0:] // ERROR "slice: omit slice operation$"27	println(z)28 29	var zs string30	zs = (**xs)[0:] // ERROR "slice: omit slice operation$"31	println(zs)32}33 
codekingpro/portable-devtools · Team Ai