github.com/Hyperledger-TWGC/tjfoc-gm@v1.4.0/gmtls/gmcredentials/credentials_util_go18.go (about)

     1  /*
     2  Copyright Suzhou Tongji Fintech Research Institute 2017 All Rights Reserved.
     3  Licensed under the Apache License, Version 2.0 (the "License");
     4  you may not use this file except in compliance with the License.
     5  You may obtain a copy of the License at
     6  
     7  	http://www.apache.org/licenses/LICENSE-2.0
     8  
     9  Unless required by applicable law or agreed to in writing, software
    10  distributed under the License is distributed on an "AS IS" BASIS,
    11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  See the License for the specific language governing permissions and
    13  limitations under the License.
    14  */
    15  
    16  package gmcredentials
    17  
    18  import gmtls "github.com/Hyperledger-TWGC/tjfoc-gm/gmtls"
    19  
    20  // cloneTLSConfig returns a shallow clone of the exported
    21  // fields of cfg, ignoring the unexported sync.Once, which
    22  // contains a mutex and must not be copied.
    23  //
    24  // If cfg is nil, a new zero tls.Config is returned.
    25  func cloneTLSConfig(cfg *gmtls.Config) *gmtls.Config {
    26  	if cfg == nil {
    27  		return &gmtls.Config{}
    28  	}
    29  
    30  	return cfg.Clone()
    31  }