How to join the elements of two slices of bytes into a string Go

1 Answer

0 votes
package main 
  
import ( 
    "bytes"
    "fmt"
) 
  
func main() { 
    slice := [][]byte{[]byte("go"),  
                      []byte("java"),  
                      []byte("php")} 
    sep := []byte(" : ") 
  

    s := bytes.Join(slice, sep) 
  
    fmt.Printf("%s", s) 
  
} 
  
   
  
    
/*
run:
     
go : java : php
 
*/

 



answered Aug 18, 2020 by avibootz

Related questions

1 answer 72 views
1 answer 149 views
149 views asked Aug 18, 2020 by avibootz
2 answers 266 views
266 views asked Aug 18, 2020 by avibootz
2 answers 249 views
249 views asked Sep 4, 2020 by avibootz
1 answer 165 views
165 views asked Aug 27, 2020 by avibootz
...