在Golang中输入名称并键入结构后的字符串是什么?

时间:2019-04-05 23:34:55

标签: go struct kubernetes-secrets

我正在看https://godoc.org/k8s.io/api/core/v1#Secret

type Secret struct {
    metav1.TypeMeta `json:",inline"`
    // Standard object's metadata.
    // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
    // +optional
    metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

    // Data contains the secret data. Each key must consist of alphanumeric
    // characters, '-', '_' or '.'. The serialized form of the secret data is a
    // base64 encoded string, representing the arbitrary (possibly non-string)
    // data value here. Described in https://tools.ietf.org/html/rfc4648#section-4
    // +optional
    Data map[string][]byte `json:"data,omitempty" protobuf:"bytes,2,rep,name=data"`

    // stringData allows specifying non-binary secret data in string form.
    // It is provided as a write-only convenience method.
    // All keys and values are merged into the data field on write, overwriting any existing values.
    // It is never output when reading from the API.
    // +k8s:conversion-gen=false
    // +optional
    StringData map[string]string `json:"stringData,omitempty" protobuf:"bytes,4,rep,name=stringData"`

    // Used to facilitate programmatic handling of secret data.
    // +optional
    Type SecretType `json:"type,omitempty" protobuf:"bytes,3,opt,name=type,casttype=SecretType"`
}

采取 例如,Data map[string][]byte `json:"data,omitempty" protobuf:"bytes,2,rep,name=data"` ,我知道Data是名称,map[string][]byte是类型,接下来的第三件事是什么?它是做什么的,什么时候需要包含这第三件事?

1 个答案:

答案 0 :(得分:1)

<head> <!-- Google Tag Manager --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '../../www.googletagmanager.com/gtm5445.html?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-PDTWJ3Z');</script> <!-- End Google Tag Manager --> <title>plotpeer</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta charset="UTF-8"> <!-- External CSS libraries --> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/bootstrap.min.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/magnific-popup.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/jquery.selectBox.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/dropzone.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/rangeslider.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/animate.min.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/leaflet.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/slick.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/slick-theme.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/slick-theme.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/map.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/css/jquery.mCustomScrollbar.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/fonts/font-awesome/css/font-awesome.min.css"> <link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/assets/fonts/flaticon/font/flaticon.css"> <!-- Favicon icon --> <link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple- icon-180x180.png"> <link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="manifest" href="/manifest.json"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/ms-icon-144x144.png"> <meta name="theme-color" content="#ffffff"> <!-- Google fonts --> <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800%7CPoppins:400,500,700,800,900%7CRoboto:100,300,400,400i,500,700"> <!-- Custom Stylesheet --> <link type="text/css" rel="stylesheet" href="assets/css/style.css"> <link rel="stylesheet" type="text/css" id="style_sheet" href="assets/css/skins/default.css"> </head> <body id="top"> <noscript>You need to enable JavaScript to run this app.</noscript> <div id="root"></div> <!-- This HTML file is a template. If you open it directly in the browser, you will see an empty page. You can add webfonts, meta tags, or analytics to this file. The build step will place the bundled scripts into the <body> tag. To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. --> <!-- External JS libraries --> <script src="/assets/js/jquery-2.2.0.min.js"></script> <script src="/assets/js/popper.min.js"></script> <script src="/assets/js/bootstrap.min.js"></script> <script src="/assets/js/jquery.selectBox.js"></script> <script src="/assets/js/rangeslider.js"></script> <script src="/assets/js/jquery.magnific-popup.min.js"></script> <script src="/assets/js/jquery.filterizr.js"></script> <script src="/assets/js/wow.min.js"></script> <script src="/assets/js/backstretch.js"></script> <script src="/assets/js/jquery.countdown.js"></script> <script src="/assets/js/jquery.scrollUp.js"></script> <script src="/assets/js/particles.min.js"></script> <script src="/assets/js/typed.min.js"></script> <script src="/assets/js/dropzone.js"></script> <script src="/assets/js/jquery.mb.YTPlayer.js"></script> <script src="/assets/js/leaflet.js"></script> <script src="/assets/js/leaflet-providers.js"></script> <script src="/assets/js/leaflet.markercluster.js"></script> <script src="/assets/js/slick.min.js"></script> <script src="/assets/js/maps.js"></script> <script src="/assets/js/jquery.mCustomScrollbar.concat.min.js"></script> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB0N5pbJN10Y1oYFRd0MJ_v2g8W2QT74JE"></script> <script src="/assets/js/ie-emulation-modes-warning.js"></script> <!-- Custom JS Script --> <script src="/assets/js/app.js"></script> i want to be able to go to localhost:300/home/ and display the page with the visuals, when i add a sub-route home/anything it loads the page but with broken assets. 被称为结构标记。关于该主题的一些有用链接是:

  • 官方语言规范here
  • 一些非常知名的here
  • 有关如何创建自定义here的教程。

标记是struct定义的一部分,可让您告诉struct如何存储数据,创建映射,进行验证等。实际上,在处理数据的Go包中会看到很多。