How to use 'strings are mutable or immutable' in Go

Every line of 'strings are mutable or immutable' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
906func (s *MySpecialStruct) AsImmutable(v *MySpecialStruct) *MySpecialStruct {
907 if s == nil {
908 return nil
909 }
910
911 if s == v {
912 return s
913 }
914
915 s.mutable = false
916 return s
917}
1272func (s *Clash1) AsImmutable(v *Clash1) *Clash1 {
1273 if s == nil {
1274 return nil
1275 }
1276
1277 if s == v {
1278 return s
1279 }
1280
1281 s.mutable = false
1282 return s
1283}

Related snippets