github.com/rahart/packer@v0.12.2-0.20161229105310-282bb6ad370f/builder/azure/common/gluestrings.go (about) 1 // Copyright (c) Microsoft Corporation. All rights reserved. 2 // Licensed under the MIT License. See the LICENSE file in builder/azure for license information. 3 4 package common 5 6 // removes overlap between the end of a and the start of b and 7 // glues them together 8 func GlueStrings(a, b string) string { 9 shift := 0 10 for shift < len(a) { 11 i := 0 12 for (i+shift < len(a)) && (i < len(b)) && (a[i+shift] == b[i]) { 13 i++ 14 } 15 if i+shift == len(a) { 16 break 17 } 18 shift++ 19 } 20 21 return string(a[:shift]) + b 22 }