github.com/cloudwego/kitex@v0.9.0/internal/mocks/update.sh (about)

     1  #!/bin/bash
     2  
     3  cd $(dirname "${BASH_SOURCE[0]}")
     4  
     5  # source file => output file => package name
     6  files=(
     7  ../../pkg/limiter/limiter.go limiter/limiter.go limiter
     8  ../../pkg/stats/tracer.go stats/tracer.go stats
     9  ../../pkg/remote/bytebuf.go remote/bytebuf.go remote
    10  ../../pkg/remote/trans_handler.go remote/trans_handler.go remote
    11  ../../pkg/remote/codec.go remote/codec.go remote
    12  ../../pkg/remote/connpool.go remote/connpool.go remote
    13  ../../pkg/remote/dialer.go remote/dialer.go remote
    14  ../../pkg/remote/trans_meta.go remote/trans_meta.go remote
    15  ../../pkg/remote/trans_pipeline.go remote/trans_pipeline.go remote
    16  ../../pkg/remote/payload_codec.go remote/payload_codec.go remote
    17  ../../pkg/generic/generic_service.go generic/generic_service.go generic
    18  ../../pkg/klog/log.go klog/log.go klog
    19  ../../pkg/generic/thrift/thrift.go generic/thrift.go generic
    20  ../../pkg/discovery/discovery.go discovery/discovery.go discovery
    21  ../../pkg/loadbalance/loadbalancer.go loadbalance/loadbalancer.go loadbalance
    22  ../../pkg/proxy/proxy.go proxy/proxy.go proxy
    23  ../../pkg/utils/sharedticker.go utils/sharedticker.go utils
    24  ../../../netpoll/connection.go netpoll/connection.go netpoll
    25  $GOROOT/src/net/net.go net/net.go net
    26  )
    27  
    28  i=0
    29  while [ $i -lt ${#files[@]} ]
    30  do
    31      infile=${files[$i]}
    32      let i++
    33      outfile=${files[$i]}
    34      let i++
    35      package=${files[$i]}
    36      let i++
    37  
    38      if [ ! -f $infile ]; then
    39          echo "ERROR: $infile not existing"
    40          exit 1
    41      fi
    42  
    43      # echo $infile
    44      # echo $outfile
    45      mockgen -source=$infile -package=$package > $outfile || exit 1
    46      if [[ "$OSTYPE" =~ ^darwin ]];
    47      then
    48        sed -i '' -e '1i \
    49  /*\
    50  \ * Copyright 2022 CloudWeGo Authors\
    51  \ *\
    52  \ * Licensed under the Apache License, Version 2.0 (the "License");\
    53  \ * you may not use this file except in compliance with the License.\
    54  \ * You may obtain a copy of the License at\
    55  \ *\
    56  \ *     http://www.apache.org/licenses/LICENSE-2.0\
    57  \ *\
    58  \ * Unless required by applicable law or agreed to in writing, software\
    59  \ * distributed under the License is distributed on an "AS IS" BASIS,\
    60  \ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\
    61  \ * See the License for the specific language governing permissions and\
    62  \ * limitations under the License.\
    63  */\
    64  \
    65  ' $outfile
    66      else
    67        sed -i '' -e '1i /*\
    68  \ * Copyright 2021 CloudWeGo Authors\
    69  \ *\
    70  \ * Licensed under the Apache License, Version 2.0 (the "License");\
    71  \ * you may not use this file except in compliance with the License.\
    72  \ * You may obtain a copy of the License at\
    73  \ *\
    74  \ *     http://www.apache.org/licenses/LICENSE-2.0\
    75  \ *\
    76  \ * Unless required by applicable law or agreed to in writing, software\
    77  \ * distributed under the License is distributed on an "AS IS" BASIS,\
    78  \ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\
    79  \ * See the License for the specific language governing permissions and\
    80  \ * limitations under the License.\
    81   */\
    82  \
    83  ' $outfile
    84      fi
    85  done