├── go.sum
├── doc
├── .gitignore
├── public
│ └── .gitignore
├── themes
│ └── hugo-geekdoc
│ │ ├── VERSION
│ │ ├── static
│ │ ├── custom.css
│ │ ├── favicon
│ │ │ ├── favicon.ico
│ │ │ ├── favicon-16x16.png
│ │ │ ├── favicon-32x32.png
│ │ │ ├── favicon-48x48.png
│ │ │ ├── mstile-144x144.png
│ │ │ ├── mstile-150x150.png
│ │ │ ├── mstile-310x150.png
│ │ │ ├── mstile-310x310.png
│ │ │ ├── mstile-70x70.png
│ │ │ ├── apple-touch-icon.png
│ │ │ ├── firefox_app_128x128.png
│ │ │ ├── firefox_app_512x512.png
│ │ │ ├── firefox_app_60x60.png
│ │ │ ├── android-chrome-36x36.png
│ │ │ ├── android-chrome-48x48.png
│ │ │ ├── android-chrome-72x72.png
│ │ │ ├── android-chrome-96x96.png
│ │ │ ├── android-chrome-144x144.png
│ │ │ ├── android-chrome-192x192.png
│ │ │ ├── android-chrome-256x256.png
│ │ │ ├── android-chrome-384x384.png
│ │ │ ├── android-chrome-512x512.png
│ │ │ ├── apple-touch-icon-114x114.png
│ │ │ ├── apple-touch-icon-120x120.png
│ │ │ ├── apple-touch-icon-144x144.png
│ │ │ ├── apple-touch-icon-152x152.png
│ │ │ ├── apple-touch-icon-167x167.png
│ │ │ ├── apple-touch-icon-180x180.png
│ │ │ ├── apple-touch-icon-57x57.png
│ │ │ ├── apple-touch-icon-60x60.png
│ │ │ ├── apple-touch-icon-72x72.png
│ │ │ ├── apple-touch-icon-76x76.png
│ │ │ ├── apple-touch-icon-1024x1024.png
│ │ │ ├── apple-touch-icon-precomposed.png
│ │ │ ├── apple-touch-startup-image-1136x640.png
│ │ │ ├── apple-touch-startup-image-1334x750.png
│ │ │ ├── apple-touch-startup-image-1792x828.png
│ │ │ ├── apple-touch-startup-image-640x1136.png
│ │ │ ├── apple-touch-startup-image-750x1334.png
│ │ │ ├── apple-touch-startup-image-828x1792.png
│ │ │ ├── apple-touch-startup-image-1125x2436.png
│ │ │ ├── apple-touch-startup-image-1242x2208.png
│ │ │ ├── apple-touch-startup-image-1242x2688.png
│ │ │ ├── apple-touch-startup-image-1536x2048.png
│ │ │ ├── apple-touch-startup-image-1620x2160.png
│ │ │ ├── apple-touch-startup-image-1668x2224.png
│ │ │ ├── apple-touch-startup-image-1668x2388.png
│ │ │ ├── apple-touch-startup-image-2048x1536.png
│ │ │ ├── apple-touch-startup-image-2048x2732.png
│ │ │ ├── apple-touch-startup-image-2160x1620.png
│ │ │ ├── apple-touch-startup-image-2208x1242.png
│ │ │ ├── apple-touch-startup-image-2224x1668.png
│ │ │ ├── apple-touch-startup-image-2388x1668.png
│ │ │ ├── apple-touch-startup-image-2436x1125.png
│ │ │ ├── apple-touch-startup-image-2688x1242.png
│ │ │ ├── apple-touch-startup-image-2732x2048.png
│ │ │ ├── manifest.webapp
│ │ │ ├── browserconfig.xml
│ │ │ ├── manifest.json
│ │ │ └── favicon.svg
│ │ ├── fonts
│ │ │ ├── Metropolis.woff
│ │ │ ├── GeekdocIcons.woff
│ │ │ ├── Metropolis.woff2
│ │ │ ├── GeekdocIcons.woff2
│ │ │ ├── KaTeX_Main-Bold.woff
│ │ │ ├── LiberationMono.woff
│ │ │ ├── LiberationMono.woff2
│ │ │ ├── LiberationSans.woff
│ │ │ ├── LiberationSans.woff2
│ │ │ ├── KaTeX_AMS-Regular.woff
│ │ │ ├── KaTeX_Main-Bold.woff2
│ │ │ ├── KaTeX_Main-Italic.woff
│ │ │ ├── KaTeX_Math-Italic.woff
│ │ │ ├── KaTeX_AMS-Regular.woff2
│ │ │ ├── KaTeX_Fraktur-Bold.woff
│ │ │ ├── KaTeX_Fraktur-Bold.woff2
│ │ │ ├── KaTeX_Main-Italic.woff2
│ │ │ ├── KaTeX_Main-Regular.woff
│ │ │ ├── KaTeX_Main-Regular.woff2
│ │ │ ├── KaTeX_Math-Italic.woff2
│ │ │ ├── KaTeX_SansSerif-Bold.woff
│ │ │ ├── KaTeX_Script-Regular.woff
│ │ │ ├── KaTeX_Size1-Regular.woff
│ │ │ ├── KaTeX_Size1-Regular.woff2
│ │ │ ├── KaTeX_Size2-Regular.woff
│ │ │ ├── KaTeX_Size2-Regular.woff2
│ │ │ ├── KaTeX_Size3-Regular.woff
│ │ │ ├── KaTeX_Size3-Regular.woff2
│ │ │ ├── KaTeX_Size4-Regular.woff
│ │ │ ├── KaTeX_Size4-Regular.woff2
│ │ │ ├── LiberationSans-Bold.woff
│ │ │ ├── LiberationSans-Bold.woff2
│ │ │ ├── KaTeX_Caligraphic-Bold.woff
│ │ │ ├── KaTeX_Fraktur-Regular.woff
│ │ │ ├── KaTeX_Fraktur-Regular.woff2
│ │ │ ├── KaTeX_Main-BoldItalic.woff
│ │ │ ├── KaTeX_Main-BoldItalic.woff2
│ │ │ ├── KaTeX_Math-BoldItalic.woff
│ │ │ ├── KaTeX_Math-BoldItalic.woff2
│ │ │ ├── KaTeX_SansSerif-Bold.woff2
│ │ │ ├── KaTeX_SansSerif-Italic.woff
│ │ │ ├── KaTeX_Script-Regular.woff2
│ │ │ ├── LiberationSans-Italic.woff
│ │ │ ├── LiberationSans-Italic.woff2
│ │ │ ├── KaTeX_Caligraphic-Bold.woff2
│ │ │ ├── KaTeX_Caligraphic-Regular.woff
│ │ │ ├── KaTeX_SansSerif-Italic.woff2
│ │ │ ├── KaTeX_SansSerif-Regular.woff
│ │ │ ├── KaTeX_SansSerif-Regular.woff2
│ │ │ ├── KaTeX_Typewriter-Regular.woff
│ │ │ ├── KaTeX_Typewriter-Regular.woff2
│ │ │ ├── LiberationSans-BoldItalic.woff
│ │ │ ├── KaTeX_Caligraphic-Regular.woff2
│ │ │ └── LiberationSans-BoldItalic.woff2
│ │ ├── js
│ │ │ ├── 273-647fed29.chunk.min.js.LICENSE.txt
│ │ │ ├── main-902b82d5.bundle.min.js.LICENSE.txt
│ │ │ ├── search-1c4cfb2d.bundle.min.js.LICENSE.txt
│ │ │ └── katex-8d0741cb.bundle.min.js
│ │ ├── print-19966b38.min.css
│ │ ├── mobile-c0e18b0e.min.css
│ │ └── brand.svg
│ │ ├── images
│ │ ├── tn.png
│ │ ├── readme.png
│ │ └── screenshot.png
│ │ ├── layouts
│ │ ├── partials
│ │ │ ├── head
│ │ │ │ ├── custom.html
│ │ │ │ ├── rel-me.html
│ │ │ │ ├── microformats.html
│ │ │ │ ├── favicons.html
│ │ │ │ ├── meta.html
│ │ │ │ └── others.html
│ │ │ ├── svg-icon-symbols.html
│ │ │ ├── utils
│ │ │ │ ├── title.html
│ │ │ │ ├── content.html
│ │ │ │ ├── featured.html
│ │ │ │ └── description.html
│ │ │ ├── foot.html
│ │ │ ├── microformats
│ │ │ │ ├── twitter_cards.html
│ │ │ │ ├── opengraph.html
│ │ │ │ └── schema.html
│ │ │ ├── search.html
│ │ │ ├── menu-extra.html
│ │ │ ├── menu.html
│ │ │ ├── posts
│ │ │ │ └── metadata.html
│ │ │ ├── language.html
│ │ │ ├── site-footer.html
│ │ │ ├── menu-nextprev.html
│ │ │ ├── page-header.html
│ │ │ ├── site-header.html
│ │ │ ├── menu-bundle.html
│ │ │ └── menu-filetree.html
│ │ ├── robots.txt
│ │ ├── shortcodes
│ │ │ ├── icon.html
│ │ │ ├── tab.html
│ │ │ ├── mermaid.html
│ │ │ ├── columns.html
│ │ │ ├── toc.html
│ │ │ ├── expand.html
│ │ │ ├── hint.html
│ │ │ ├── include.html
│ │ │ ├── tabs.html
│ │ │ ├── katex.html
│ │ │ ├── button.html
│ │ │ ├── toc-tree.html
│ │ │ ├── propertylist.html
│ │ │ └── img.html
│ │ ├── _default
│ │ │ ├── _markup
│ │ │ │ ├── render-image.html
│ │ │ │ ├── render-codeblock-mermaid.html
│ │ │ │ ├── render-link.html
│ │ │ │ └── render-heading.html
│ │ │ ├── list.html
│ │ │ ├── single.html
│ │ │ ├── terms.html
│ │ │ ├── taxonomy.html
│ │ │ └── baseof.html
│ │ ├── posts
│ │ │ ├── single.html
│ │ │ └── list.html
│ │ └── 404.html
│ │ ├── .linkcheckignore
│ │ ├── archetypes
│ │ ├── posts.md
│ │ └── docs.md
│ │ ├── theme.toml
│ │ ├── assets
│ │ └── search
│ │ │ ├── config.json
│ │ │ └── data.json
│ │ ├── LICENSE
│ │ ├── i18n
│ │ ├── zh-cn.yaml
│ │ ├── ja.yaml
│ │ ├── en.yaml
│ │ ├── de.yaml
│ │ └── it.yaml
│ │ └── README.md
├── layouts
│ └── .gitignore
├── content
│ ├── en
│ │ ├── type
│ │ │ ├── _index.md
│ │ │ ├── time.md
│ │ │ ├── float.md
│ │ │ ├── map.md
│ │ │ ├── int.md
│ │ │ ├── string.md
│ │ │ ├── others.md
│ │ │ ├── bool.md
│ │ │ └── slice.md
│ │ ├── usage
│ │ │ ├── _index.md
│ │ │ └── getting-started.md
│ │ ├── develop
│ │ │ ├── _index.md
│ │ │ ├── testing.md
│ │ │ └── 32bit.md
│ │ └── _index.md
│ └── zh-cn
│ │ ├── type
│ │ ├── _index.md
│ │ ├── float.md
│ │ ├── map.md
│ │ ├── int.md
│ │ ├── time.md
│ │ ├── string.md
│ │ ├── others.md
│ │ ├── bool.md
│ │ └── slice.md
│ │ ├── usage
│ │ ├── _index.md
│ │ └── getting-started.md
│ │ ├── develop
│ │ ├── _index.md
│ │ ├── testing.md
│ │ └── 32bit.md
│ │ └── _index.md
├── vercel.json
├── archetypes
│ └── default.md
├── data
│ └── menu
│ │ └── extra.yaml
├── config
│ └── _default
│ │ └── languages.yaml
├── netlify.toml
├── config.toml
└── static
│ └── custom.css
├── go.mod
├── .travis.yml
├── .editorconfig
├── .github
└── workflows
│ ├── reviewdog.yml
│ └── go.yml
├── Dockerfile.32bit
├── .gitignore
├── LICENSE
├── Makefile
├── README_ZH.md
├── string.go
├── README.md
├── bool.go
├── map.go
├── float.go
├── time.go
├── map_test.go
└── slice.go
/go.sum:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/doc/.gitignore:
--------------------------------------------------------------------------------
1 | .hugo_build.lock
2 |
--------------------------------------------------------------------------------
/doc/public/.gitignore:
--------------------------------------------------------------------------------
1 | !.gitignore
2 | *
3 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/VERSION:
--------------------------------------------------------------------------------
1 | v0.35.1
2 |
--------------------------------------------------------------------------------
/doc/layouts/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/shockerli/cvt
2 |
3 | go 1.13
4 |
--------------------------------------------------------------------------------
/doc/content/en/type/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Type
3 | weight: 20
4 | ---
5 |
--------------------------------------------------------------------------------
/doc/content/en/usage/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Usage
3 | weight: 10
4 | ---
5 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 类型
3 | weight: 20
4 | ---
5 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/usage/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 开始
3 | weight: 10
4 | ---
5 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/develop/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 开发
3 | weight: 30
4 | ---
5 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/custom.css:
--------------------------------------------------------------------------------
1 | /* You can add custom styles here. */
2 |
--------------------------------------------------------------------------------
/doc/content/en/develop/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Development
3 | weight: 30
4 | ---
5 |
--------------------------------------------------------------------------------
/doc/vercel.json:
--------------------------------------------------------------------------------
1 | {
2 | "build": {
3 | "env": {
4 | "HUGO_VERSION": "0.101.0"
5 | }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/images/tn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/images/tn.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/head/custom.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/.linkcheckignore:
--------------------------------------------------------------------------------
1 | .*/fonts/KaTeX_.*.ttf
2 | https://github.com/thegeeklab/hugo-geekdoc/edit/main/.*
3 |
--------------------------------------------------------------------------------
/doc/archetypes/default.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "{{ replace .Name "-" " " | title }}"
3 | date: {{ .Date }}
4 | draft: true
5 | ---
6 |
7 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/archetypes/posts.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "{{ replace .Name "-" " " | title }}"
3 | date: {{ .Date }}
4 | ---
5 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/images/readme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/images/readme.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow: /tags/*
3 |
4 | Sitemap: {{ "sitemap.xml" | absURL }}
5 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/head/rel-me.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/images/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/images/screenshot.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/favicon.ico
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/Metropolis.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/Metropolis.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/js/273-647fed29.chunk.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /*! For license information please see mermaid.esm.min.mjs.LICENSE.txt */
2 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/GeekdocIcons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/GeekdocIcons.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/Metropolis.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/Metropolis.woff2
--------------------------------------------------------------------------------
/doc/data/menu/extra.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | header:
3 | - name: GitHub
4 | ref: https://github.com/shockerli/cvt
5 | icon: gdoc_github
6 | external: true
7 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/favicon-16x16.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/favicon-32x32.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/favicon-48x48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/favicon-48x48.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/mstile-144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/mstile-144x144.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/mstile-150x150.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/mstile-310x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/mstile-310x150.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/mstile-310x310.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/mstile-310x310.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/mstile-70x70.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/mstile-70x70.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/GeekdocIcons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/GeekdocIcons.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Bold.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationMono.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationMono.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationMono.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationMono.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationSans.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationSans.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationSans.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationSans.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_AMS-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_AMS-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Bold.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Italic.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Math-Italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Math-Italic.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/firefox_app_128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/firefox_app_128x128.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/firefox_app_512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/firefox_app_512x512.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/firefox_app_60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/firefox_app_60x60.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_AMS-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_AMS-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Fraktur-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Fraktur-Bold.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Fraktur-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Fraktur-Bold.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Italic.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Math-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Math-Italic.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Bold.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Script-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Script-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size1-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size1-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size1-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size1-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size2-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size2-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size2-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size2-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size3-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size3-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size3-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size3-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size4-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size4-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size4-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Size4-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-Bold.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-Bold.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-36x36.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-36x36.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-48x48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-48x48.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-72x72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-72x72.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-96x96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-96x96.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Caligraphic-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Caligraphic-Bold.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Fraktur-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Fraktur-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Fraktur-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Fraktur-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-BoldItalic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-BoldItalic.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-BoldItalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Main-BoldItalic.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Math-BoldItalic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Math-BoldItalic.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Math-BoldItalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Math-BoldItalic.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Bold.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Italic.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Script-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Script-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-Italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-Italic.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-Italic.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-144x144.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-192x192.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-256x256.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-384x384.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-384x384.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/android-chrome-512x512.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-114x114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-114x114.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-144x144.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-167x167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-167x167.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-57x57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-57x57.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-72x72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-72x72.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Caligraphic-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Caligraphic-Bold.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Caligraphic-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Caligraphic-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Italic.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_SansSerif-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Typewriter-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Typewriter-Regular.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Typewriter-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Typewriter-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-BoldItalic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-BoldItalic.woff
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-1024x1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-1024x1024.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Caligraphic-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/KaTeX_Caligraphic-Regular.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-BoldItalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/fonts/LiberationSans-BoldItalic.woff2
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-icon-precomposed.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/js/main-902b82d5.bundle.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /*!
2 | * clipboard.js v2.0.11
3 | * https://clipboardjs.com/
4 | *
5 | * Licensed MIT © Zeno Rocha
6 | */
7 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/archetypes/docs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "{{ .Name | humanize | title }}"
3 | weight: 1
4 | # geekdocFlatSection: false
5 | # geekdocToc: 6
6 | # geekdocHidden: false
7 | ---
8 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/icon.html:
--------------------------------------------------------------------------------
1 | {{ $id := .Get 0 }}
2 |
3 | {{- with $id -}}
4 |
5 | {{- end -}}
6 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1136x640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1136x640.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1334x750.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1334x750.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1792x828.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1792x828.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-640x1136.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-640x1136.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-750x1334.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-750x1334.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-828x1792.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-828x1792.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1125x2436.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1125x2436.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1242x2208.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1242x2208.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1242x2688.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1242x2688.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1536x2048.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1536x2048.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1620x2160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1620x2160.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1668x2224.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1668x2224.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1668x2388.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-1668x2388.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2048x1536.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2048x1536.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2048x2732.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2048x2732.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2160x1620.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2160x1620.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2208x1242.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2208x1242.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2224x1668.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2224x1668.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2388x1668.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2388x1668.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2436x1125.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2436x1125.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2688x1242.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2688x1242.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2732x2048.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shockerli/cvt/HEAD/doc/themes/hugo-geekdoc/static/favicon/apple-touch-startup-image-2732x2048.png
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/head/microformats.html:
--------------------------------------------------------------------------------
1 | {{ partial "microformats/opengraph.html" . }}
2 | {{ partial "microformats/twitter_cards.html" . }}
3 | {{ partial "microformats/schema" . }}
4 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/svg-icon-symbols.html:
--------------------------------------------------------------------------------
1 | {{ range resources.Match "sprites/*.svg" }}
2 | {{ printf "" . | safeHTML }}
3 | {{ .Content | safeHTML }}
4 | {{ end }}
5 |
--------------------------------------------------------------------------------
/doc/config/_default/languages.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | en:
3 | languageName: "English"
4 | contentDir: "content/en"
5 | weight: 10
6 |
7 | zh-cn:
8 | languageName: "简体中文"
9 | contentDir: "content/zh-cn"
10 | weight: 20
11 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/_markup/render-image.html:
--------------------------------------------------------------------------------
1 |
6 | {{- /* Drop trailing newlines */ -}}
7 |
--------------------------------------------------------------------------------
/doc/netlify.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | publish = "public"
3 | command = "hugo --gc --minify"
4 |
5 | [context.deploy-preview.environment]
6 | HUGO_VERSION = "0.101.0"
7 |
8 | [context.production.environment]
9 | HUGO_VERSION = "0.101.0"
10 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/develop/testing.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 测试
3 | weight: 20
4 | ---
5 |
6 | ## 命名约定
7 |
8 | - `TestXXX_HasDefault`:测试带有默认值的方法
9 | - `TestXXX_BaseLine`:测试没有带默认值的无错误方法
10 | - `TestXXXE`:测试返回错误信息的方法
11 | - `TestXXXP`:测试返回数据指针的方法
12 |
13 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/js/search-1c4cfb2d.bundle.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**!
2 | * FlexSearch.js v0.7.21 (Compact)
3 | * Copyright 2018-2021 Nextapps GmbH
4 | * Author: Thomas Wilkerling
5 | * Licence: Apache-2.0
6 | * https://github.com/nextapps-de/flexsearch
7 | */
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 |
3 | os:
4 | - linux
5 |
6 | jobs:
7 | include:
8 | - go: "1.13.x"
9 | env: GO111MODULE=on
10 | - go: "1.14.x"
11 | env: GO111MODULE=on
12 | - go: master
13 | env: GO111MODULE=on
14 |
15 | script:
16 | - make check
17 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | ; http://editorconfig.org/
2 |
3 | root = true
4 |
5 | [*]
6 | charset = utf-8
7 | end_of_line = lf
8 | insert_final_newline = true
9 | indent_size = 2
10 | indent_style = space
11 | trim_trailing_whitespace = true
12 |
13 | [{Makefile,go.mod,go.sum,*.go}]
14 | indent_size = 4
15 | indent_style = tab
16 |
--------------------------------------------------------------------------------
/doc/content/en/develop/testing.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Testing
3 | weight: 20
4 | ---
5 |
6 | ## 命名约定
7 |
8 | - `TestXXX_HasDefault`:Test method with default values
9 | - `TestXXX_BaseLine`:Test is error-free method with default values
10 | - `TestXXXE`:Method to test the return error information
11 | - `TestXXXP`:Return a pointer to the data of the test method
12 |
13 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/list.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 | {{ partial "page-header" . }}
3 |
4 |
5 |
8 | {{ partial "utils/title" . }}
9 | {{ partial "utils/content" . }}
10 |
11 | {{ end }}
12 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/utils/title.html:
--------------------------------------------------------------------------------
1 | {{ $title := "" }}
2 |
3 | {{ if .Title }}
4 | {{ $title = .Title }}
5 | {{ else if and .IsSection .File }}
6 | {{ $title = path.Base .File.Dir | humanize | title }}
7 | {{ else if and .IsPage .File }}
8 | {{ $title = .File.BaseFileName | humanize | title }}
9 | {{ end }}
10 |
11 | {{ return $title }}
12 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/single.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 | {{ partial "page-header" . }}
3 |
4 |
5 |
8 | {{ partial "utils/title" . }}
9 | {{ partial "utils/content" . }}
10 |
11 | {{ end }}
12 |
--------------------------------------------------------------------------------
/.github/workflows/reviewdog.yml:
--------------------------------------------------------------------------------
1 | name: reviewdog
2 | on: [ pull_request ]
3 | jobs:
4 | golangci-lint:
5 | name: runner / golangci-lint
6 | runs-on: ubuntu-latest
7 | steps:
8 | - name: Check out code into the Go module directory
9 | uses: actions/checkout@v2
10 |
11 | - name: golangci-lint
12 | uses: reviewdog/action-golangci-lint@v2
13 |
--------------------------------------------------------------------------------
/Dockerfile.32bit:
--------------------------------------------------------------------------------
1 | FROM i386/golang:alpine
2 |
3 | RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
4 | apk update && \
5 | apk add --no-cache bash git openssh ca-certificates tzdata && \
6 | rm -rf /var/cache/apk/*
7 |
8 | ENV CGO_ENABLED=0 \
9 | GOPROXY="https://goproxy.cn"
10 |
11 | WORKDIR /usr/src/myapp
12 |
13 | CMD ["bash"]
14 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/manifest.webapp:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "name": "geekdoc",
4 | "description": "Hugo theme made for documentation",
5 | "icons": {
6 | "60": "firefox_app_60x60.png",
7 | "128": "firefox_app_128x128.png",
8 | "512": "firefox_app_512x512.png"
9 | },
10 | "developer": {
11 | "name": "Robert Kaussow",
12 | "url": null
13 | }
14 | }
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/head/favicons.html:
--------------------------------------------------------------------------------
1 |
2 |
8 |
14 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/utils/content.html:
--------------------------------------------------------------------------------
1 | {{ $content := .Content }}
2 |
3 | {{ $content = $content | replaceRE `\s*\s* ` `` | safeHTML }}
4 | {{ $content = $content | replaceRE `(
)` ` ${1}
` | safeHTML }}
5 |
6 | {{ return $content }}
7 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/foot.html:
--------------------------------------------------------------------------------
1 | {{ if default true .Site.Params.GeekdocSearch }}
2 |
3 | {{- $searchConfigFile := printf "search/%s.config.json" .Language.Lang -}}
4 | {{- $searchConfig := resources.Get "search/config.json" | resources.ExecuteAsTemplate $searchConfigFile . | resources.Minify -}}
5 | {{- $searchConfig.Publish -}}
6 | {{ end }}
7 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/tab.html:
--------------------------------------------------------------------------------
1 | {{ if .Parent }}
2 | {{ $name := .Get 0 }}
3 | {{ $group := printf "tabs-%s" (.Parent.Get 0) }}
4 |
5 | {{ if not (.Parent.Scratch.Get $group) }}
6 | {{ .Parent.Scratch.Set $group slice }}
7 | {{ end }}
8 |
9 | {{ .Parent.Scratch.Add $group (dict "Name" $name "Content" .Inner) }}
10 | {{ else }}
11 | {{ errorf "%q: 'tab' shortcode must be inside 'tabs' shortcode" .Page.Path }}
12 | {{ end }}
13 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/theme.toml:
--------------------------------------------------------------------------------
1 | name = "Geekdoc"
2 | license = "MIT"
3 | licenselink = "https://github.com/thegeeklab/hugo-geekdoc/blob/main/LICENSE"
4 | description = "Hugo theme made for documentation"
5 | homepage = "https://geekdocs.de/"
6 | demosite = "https://geekdocs.de/"
7 | tags = ["docs", "documentation", "responsive", "simple"]
8 | min_version = "0.93.0"
9 |
10 | [author]
11 | name = "Robert Kaussow"
12 | homepage = "https://thegeeklab.de/"
13 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/assets/search/config.json:
--------------------------------------------------------------------------------
1 | {{- $searchDataFile := printf "search/%s.data.json" .Language.Lang -}}
2 | {{- $searchData := resources.Get "search/data.json" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify -}}
3 | {
4 | "dataFile": {{ $searchData.RelPermalink | jsonify }},
5 | "indexConfig": {{ .Site.Params.GeekdocSearchConfig | jsonify }},
6 | "showParent": {{ if .Site.Params.GeekdocSearchShowParent }}true{{ else }}false{{ end }}
7 | }
8 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/_markup/render-codeblock-mermaid.html:
--------------------------------------------------------------------------------
1 |
2 | {{ if not (.Page.Scratch.Get "mermaid") }}
3 |
4 |
5 | {{ .Page.Scratch.Set "mermaid" true }}
6 | {{ end }}
7 |
8 |
9 |
10 | {{- .Inner -}}
11 |
12 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/utils/featured.html:
--------------------------------------------------------------------------------
1 | {{ $img := "" }}
2 |
3 | {{ with $source := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }}
4 | {{ $featured := .Fill (printf "1200x630 %s" (default "Smart" .Params.anchor)) }}
5 | {{ $img = $featured.Permalink }}
6 | {{ else }}
7 | {{ with default $.Site.Params.images $.Params.images }}
8 | {{ $img = index . 0 | absURL }}
9 | {{ end }}
10 | {{ end }}
11 |
12 | {{ return $img }}
13 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/develop/32bit.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 32位测试
3 | weight: 10
4 | ---
5 |
6 |
7 | 使用 `i386/golang:alpine` 镜像进行 32 位测试,`Docker` 配置查看文件 `Dockerfile.32bit`。
8 |
9 |
10 |
11 | - 构建镜像
12 |
13 | ```shell
14 | docker build -t cvt-test -f Dockerfile.32bit .
15 | ```
16 |
17 | - 运行容器
18 |
19 | ```shell
20 | docker run -it --name cvt-test -v "$PWD":/usr/src/myapp -w /usr/src/myapp cvt-test bash
21 | ```
22 |
23 | - 运行测试
24 |
25 | ```shell
26 | go test ./...
27 | ```
28 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/mermaid.html:
--------------------------------------------------------------------------------
1 |
2 | {{ if not (.Page.Scratch.Get "mermaid") }}
3 |
4 |
5 | {{ .Page.Scratch.Set "mermaid" true }}
6 | {{ end }}
7 |
8 |
9 |
10 | {{- .Inner -}}
11 |
12 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/assets/search/data.json:
--------------------------------------------------------------------------------
1 | [
2 | {{ range $index, $page := (where .Site.Pages "Params.GeekdocProtected" "ne" true) }}
3 | {{ if ne $index 0 }},{{ end }}
4 | {
5 | "id": {{ $index }},
6 | "href": "{{ $page.RelPermalink }}",
7 | "title": {{ (partial "utils/title" $page) | jsonify }},
8 | "parent": {{ with $page.Parent }}{{ (partial "utils/title" .) | jsonify }}{{ else }}""{{ end }},
9 | "content": {{ $page.Plain | jsonify }}
10 | }
11 | {{ end }}
12 | ]
13 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/_markup/render-link.html:
--------------------------------------------------------------------------------
1 | {{- $raw := or (hasPrefix .Text "
12 | {{- .Text | safeHTML -}}
13 |
14 | {{- /* Drop trailing newlines */ -}}
15 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/utils/description.html:
--------------------------------------------------------------------------------
1 | {{ $isPage := or (and (ne .Type "posts") (in "section page" .Kind )) (and (eq .Type "posts") (eq .Kind "page")) }}
2 | {{ $description := "" }}
3 |
4 | {{ if .Description }}
5 | {{ $description = .Description }}
6 | {{ else }}
7 | {{ if $isPage }}
8 | {{ $description = .Summary }}
9 | {{ else if .Site.Params.description }}
10 | {{ $description = .Site.Params.description }}
11 | {{ end }}
12 | {{ end }}
13 |
14 | {{ return $description }}
15 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/columns.html:
--------------------------------------------------------------------------------
1 | {{- $size := default "regular" (.Get "size" | lower) }}
2 |
3 | {{- if not (in (slice "regular" "large" "small") $size) }}
4 | {{- $size = "regular" }}
5 | {{- end }}
6 |
7 |
8 |
9 | {{ range split .Inner "<--->" }}
10 |
11 | {{ . | $.Page.RenderString }}
12 |
13 | {{ end }}
14 |
15 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/toc.html:
--------------------------------------------------------------------------------
1 | {{- $format := default "html" (.Get "format") }}
2 | {{- $tocLevels := default (default 6 .Site.Params.GeekdocToC) .Page.Params.GeekdocToC }}
3 |
4 | {{- if and $tocLevels .Page.TableOfContents -}}
5 | {{- if not (eq ($format | lower) "raw") -}}
6 |
7 | {{ .Page.TableOfContents }}
8 |
9 |
10 | {{- else -}}
11 | {{ .Page.TableOfContents }}
12 | {{- end -}}
13 | {{- end -}}
14 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/posts/single.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 |
3 |
9 |
10 | {{ partial "utils/content" . }}
11 |
12 |
13 | {{ end }}
14 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/browserconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | #2f333e
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/doc/content/en/develop/32bit.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Test in 32bit
3 | weight: 10
4 | ---
5 |
6 |
7 | Use `i386/golang:alpine` image for testing 32bit system, detail in `Dockerfile.32bit`
8 |
9 |
10 |
11 | - build image
12 |
13 | ```shell
14 | docker build -t cvt-test -f Dockerfile.32bit .
15 | ```
16 |
17 | - run container
18 |
19 | ```shell
20 | docker run -it --name cvt-test -v "$PWD":/usr/src/myapp -w /usr/src/myapp cvt-test bash
21 | ```
22 |
23 | - run test
24 |
25 | ```shell
26 | go test ./...
27 | ```
28 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/print-19966b38.min.css:
--------------------------------------------------------------------------------
1 | @media print{.gdoc-nav,.gdoc-footer .container span:not(:first-child),.editpage{display:none}.gdoc-footer{border-top:1px solid #dee2e6}.gdoc-markdown pre{white-space:pre-wrap;overflow-wrap:break-word}.chroma code{border:1px solid #dee2e6;padding:.5rem !important;font-weight:normal !important}.gdoc-markdown code{font-weight:bold}a,a:visited{color:inherit !important;text-decoration:none !important}.gdoc-toc{flex:none}.gdoc-toc nav{position:relative;width:auto}.wrapper{display:block}.wrapper main{display:block}}
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/expand.html:
--------------------------------------------------------------------------------
1 | {{ $id := substr (sha1 .Inner) 0 8 }}
2 |
3 |
4 | {{ default "Expand" (.Get 0) }}
5 | {{ default "↕" (.Get 1) }}
6 |
7 |
8 |
9 | {{ .Inner | $.Page.RenderString | htmlUnescape | safeHTML }}
10 |
11 |
12 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/head/meta.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ hugo.Generator }}
6 |
7 | {{ $keywords := default .Site.Params.Keywords .Keywords }}
8 |
9 | {{- with partial "utils/description" . }}
10 |
11 | {{- end }}
12 | {{- with $keywords }}
13 |
14 | {{- end }}
15 |
--------------------------------------------------------------------------------
/doc/config.toml:
--------------------------------------------------------------------------------
1 | baseURL = "https://cvt.shockerli.net"
2 | title = "cvt"
3 | theme = "hugo-geekdoc"
4 |
5 | defaultContentLanguage = 'en'
6 |
7 | pluralizeListTitles = false
8 |
9 | # Geekdoc required configuration
10 | pygmentsUseClasses = true
11 | pygmentsCodeFences = true
12 | disablePathToLower = true
13 |
14 | # Required if you want to render robots.txt template
15 | enableRobotsTXT = true
16 |
17 | # Needed for mermaid shortcodes
18 | [markup]
19 | [markup.goldmark.renderer]
20 | # Needed for mermaid shortcode
21 | unsafe = true
22 | [markup.tableOfContents]
23 | startLevel = 1
24 | endLevel = 9
25 |
26 | [taxonomies]
27 | tag = "tags"
28 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/hint.html:
--------------------------------------------------------------------------------
1 | {{ $type := default "note" (.Get "type") }}
2 | {{ $icon := .Get "icon" }}
3 | {{ $title := default ($type | title) (.Get "title") }}
4 |
5 |
6 |
7 |
8 | {{- with $icon -}}
9 |
10 | {{ $title }}
11 | {{- else -}}
12 |
13 | {{- end -}}
14 |
15 | {{ .Inner | $.Page.RenderString }}
16 |
17 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/include.html:
--------------------------------------------------------------------------------
1 | {{ $file := .Get "file" }}
2 | {{ $page := .Site.GetPage $file }}
3 | {{ $type := .Get "type" }}
4 | {{ $language := .Get "language" }}
5 | {{ $options :=.Get "options" }}
6 |
7 |
8 |
9 | {{- if (.Get "language") -}}
10 | {{- highlight ($file | readFile) $language (default "linenos=table" $options) -}}
11 | {{- else if eq $type "html" -}}
12 | {{- $file | readFile | safeHTML -}}
13 | {{- else if eq $type "page" -}}
14 | {{- with $page }}{{ .Content }}{{ end -}}
15 | {{- else -}}
16 | {{- $file | readFile | $.Page.RenderString -}}
17 | {{- end -}}
18 |
19 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/microformats/twitter_cards.html:
--------------------------------------------------------------------------------
1 | {{- with partial "utils/featured" . }}
2 |
3 | {{- else }}
4 |
5 | {{- end }}
6 |
7 | {{- with partial "utils/featured" . }}
8 |
9 | {{- end }}
10 | {{- with partial "utils/description" . }}
11 |
12 | {{- end }}
13 | {{- with .Site.Social.twitter -}}
14 |
15 | {{- end }}
16 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/tabs.html:
--------------------------------------------------------------------------------
1 | {{ if .Inner }}{{ end }}
2 | {{ $id := .Get 0 }}
3 | {{ $group := printf "tabs-%s" $id }}
4 |
5 |
6 |
7 | {{ range $index, $tab := .Scratch.Get $group }}
8 |
15 |
16 | {{ $tab.Name }}
17 |
18 |
19 | {{ .Content | $.Page.RenderString }}
20 |
21 | {{ end }}
22 |
23 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/katex.html:
--------------------------------------------------------------------------------
1 |
2 | {{ if not (.Page.Scratch.Get "katex") }}
3 |
4 |
8 |
9 | {{ .Page.Scratch.Set "katex" true }}
10 | {{ end }}
11 |
12 |
13 |
14 | {{ cond (in .Params "display") "\\[" "\\(" -}}
15 | {{- trim .Inner "\n" -}}
16 | {{- cond (in .Params "display") "\\]" "\\)" -}}
17 |
18 | {{- /* Drop trailing newlines */ -}}
19 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/search.html:
--------------------------------------------------------------------------------
1 | {{ if default true .Site.Params.GeekdocSearch }}
2 |
17 | {{ end }}
18 |
--------------------------------------------------------------------------------
/doc/content/en/type/time.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Time
3 | weight: 50
4 | ---
5 |
6 |
7 | {{< toc >}}
8 |
9 | ## Time
10 |
11 | ## TimeE
12 |
13 | ```go
14 | cvt.Time("2009-11-10 23:00:00 +0000 UTC")
15 | cvt.Time("2018-10-21T23:21:29+0200")
16 | cvt.Time("10 Nov 09 23:00 UTC")
17 | cvt.Time("2009-11-10T23:00:00Z")
18 | cvt.Time("11:00PM")
19 | cvt.Time("2006-01-02")
20 | cvt.Time("2016-03-06 15:28:01")
21 | cvt.Time(1482597504)
22 | cvt.Time(time.Date(2009, 2, 13, 23, 31, 30, 0, time.Local))
23 | ```
24 |
25 | ## TimeInLocation
26 | cvt.TimeInLocation("2009-02-13 23:31:30", time.FixedZone("UTC", 8*3600))
27 |
28 | ## TimeInLocationE
29 | cvt.TimeInLocationE("2009-02-13 23:31:30", time.FixedZone("UTC", 8*3600))
30 |
31 |
32 | > More case see unit: `time_test.go`
33 |
34 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/button.html:
--------------------------------------------------------------------------------
1 | {{- $ref := "" }}
2 | {{- $class := "" }}
3 | {{- $size := default "regular" (.Get "size" | lower) }}
4 |
5 | {{- if not (in (slice "regular" "large") $size) }}
6 | {{- $size = "regular" }}
7 | {{- end }}
8 |
9 | {{- with .Get "href" }}
10 | {{- $ref = . }}
11 | {{- end }}
12 |
13 | {{- with .Get "relref" }}
14 | {{- $ref = relref $ . }}
15 | {{- end }}
16 |
17 | {{- with .Get "class" }}
18 | {{- $class = . }}
19 | {{- end }}
20 |
21 |
22 |
23 |
27 | {{ $.Inner }}
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Git ###
2 | # Created by git for backups. To disable backups in Git:
3 | # $ git config --global mergetool.keepBackup false
4 | *.orig
5 |
6 | # Created by git when using merge tools for conflicts
7 | *.BACKUP.*
8 | *.BASE.*
9 | *.LOCAL.*
10 | *.REMOTE.*
11 | *_BACKUP_*.txt
12 | *_BASE_*.txt
13 | *_LOCAL_*.txt
14 | *_REMOTE_*.txt
15 |
16 | ### Go ###
17 | # Binaries for programs and plugins
18 | *.exe
19 | *.exe~
20 | *.dll
21 | *.so
22 | *.dylib
23 |
24 | # Test binary, built with `go test -c`
25 | *.test
26 |
27 | # Output of the go coverage tool, specifically when used with LiteIDE
28 | *.out
29 |
30 | # Dependency directories (remove the comment below to include it)
31 | # vendor/
32 |
33 | ### Go Patch ###
34 | /vendor/
35 | /Godeps/
36 |
37 | ### JetBrains ###
38 | .idea
39 |
40 | ### SVN ###
41 | .svn/
42 |
43 | /tmp
44 |
--------------------------------------------------------------------------------
/doc/content/en/type/float.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Float
3 | weight: 30
4 | ---
5 |
6 |
7 | {{< toc >}}
8 |
9 |
10 | ## Function
11 | - Float32
12 | - Float32E
13 | - Float32P
14 | - Float64
15 | - Float64E
16 | - Float64P
17 |
18 |
19 | ## Examples
20 | ```go
21 | cvt.Float64(int32(8)) // 8
22 | cvt.Float64(float32(8.31)) // 8.31
23 | cvt.Float64("-8") // 8
24 | cvt.Float64("-8.01") // 8.01
25 | cvt.Float64(nil) // 0
26 | cvt.Float64(true) // 1
27 | cvt.Float64(false) // 0
28 |
29 | type AliasTypeInt int
30 | type PointerTypeInt *AliasTypeInt
31 | cvt.Float64(AliasTypeInt(8)) // 8
32 | cvt.Float64((*AliasTypeInt)(nil)) // 0
33 | cvt.FLoat64((*PointerTypeInt)(nil)) // 0
34 |
35 | cvt.Float64P("12.3") // (*float64)(0x14000126180)(12.3)
36 | ```
37 |
38 | > More case see unit: `float_test.go`
39 |
40 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/float.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Float
3 | weight: 30
4 | ---
5 |
6 | 安全的转换数据为浮点型。
7 |
8 | {{< toc >}}
9 |
10 |
11 | ## 方法
12 | - Float32
13 | - Float32E
14 | - Float32P
15 | - Float64
16 | - Float64E
17 | - Float64P
18 |
19 |
20 | ## 示例
21 | ```go
22 | cvt.Float64(int32(8)) // 8
23 | cvt.Float64(float32(8.31)) // 8.31
24 | cvt.Float64("-8") // 8
25 | cvt.Float64("-8.01") // 8.01
26 | cvt.Float64(nil) // 0
27 | cvt.Float64(true) // 1
28 | cvt.Float64(false) // 0
29 |
30 | type AliasTypeInt int
31 | type PointerTypeInt *AliasTypeInt
32 | cvt.Float64(AliasTypeInt(8)) // 8
33 | cvt.Float64((*AliasTypeInt)(nil)) // 0
34 | cvt.FLoat64((*PointerTypeInt)(nil)) // 0
35 |
36 | cvt.Float64P("12.3") // (*float64)(0x14000126180)(12.3)
37 | ```
38 |
39 | > 更多示例请看单元测试:`float_test.go`
40 |
41 |
--------------------------------------------------------------------------------
/.github/workflows/go.yml:
--------------------------------------------------------------------------------
1 | name: Go
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 |
9 | # This enables a "Run workflow" button on the Actions tab
10 | workflow_dispatch:
11 |
12 | jobs:
13 | build:
14 | strategy:
15 | matrix:
16 | go-version: [ 1.13, 1.18 ]
17 | os: [ ubuntu-latest ]
18 | runs-on: ${{ matrix.os }}
19 | steps:
20 | - uses: actions/checkout@v2
21 |
22 | - name: Setup Go
23 | uses: actions/setup-go@v2
24 | with:
25 | go-version: ${{ matrix.go-version }}
26 |
27 | - name: Run tests
28 | run: make test-race fmt vet
29 |
30 | - name: Upload coverage to Codecov
31 | if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.go-version == '1.13' }}
32 | run: |
33 | go test -coverprofile=coverage.txt -covermode=atomic ./...
34 | bash <(curl -s https://codecov.io/bash)
35 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/map.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Map
3 | weight: 70
4 | ---
5 |
6 | {{< toc >}}
7 |
8 |
9 | ## StringMapE
10 |
11 | - Map
12 |
13 | ```go
14 | // expect: map[string]interface{}{"111": "cvt", "222": 3.21}
15 | cvt.StringMapE(map[interface{}]interface{}{111: "cvt", "222": 3.21})
16 | ```
17 |
18 | - Struct
19 |
20 | ```go
21 | // expect: map[string]interface{}{"Name": "cvt", "Age": 3}
22 | cvt.StringMapE(struct {
23 | Name string
24 | Age int
25 | }{"cvt", 3})
26 | ```
27 |
28 | - JSON
29 |
30 | ```go
31 | // expect: map[string]interface{}{"name": "cvt", "age": 3.21}
32 | cvt.StringMapE(`{"name":"cvt","age":3.21}`)
33 | ```
34 |
35 | ## IntMapE
36 |
37 | - Map
38 |
39 | ```go
40 | // expect: map[int]interface{}{111: "cvt", 222: 3.21}
41 | cvt.IntMapE(map[interface{}]interface{}{111: "cvt", "222": 3.21})
42 | ```
43 |
44 | - JSON
45 |
46 | ```go
47 | // expect: map[int]interface{}{1: "cvt", 2: 3.21}
48 | cvt.IntMapE(`{"1":"cvt","2":3.21}`)
49 | ```
50 |
51 | > 更多示例请看单元测试:`map_test.go`
52 |
53 |
--------------------------------------------------------------------------------
/doc/content/en/type/map.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Map
3 | weight: 70
4 | ---
5 |
6 | {{< toc >}}
7 |
8 |
9 | ## StringMapE
10 |
11 | - Map
12 |
13 | ```go
14 | // expect: map[string]interface{}{"111": "cvt", "222": 3.21}
15 | cvt.StringMapE(map[interface{}]interface{}{111: "cvt", "222": 3.21})
16 | ```
17 |
18 | - Struct
19 |
20 | ```go
21 | // expect: map[string]interface{}{"Name": "cvt", "Age": 3}
22 | cvt.StringMapE(struct {
23 | Name string
24 | Age int
25 | }{"cvt", 3})
26 | ```
27 |
28 | - JSON
29 |
30 | ```go
31 | // expect: map[string]interface{}{"name": "cvt", "age": 3.21}
32 | cvt.StringMapE(`{"name":"cvt","age":3.21}`)
33 | ```
34 |
35 | ## IntMapE
36 |
37 | - Map
38 |
39 | ```go
40 | // expect: map[int]interface{}{111: "cvt", 222: 3.21}
41 | cvt.IntMapE(map[interface{}]interface{}{111: "cvt", "222": 3.21})
42 | ```
43 |
44 | - JSON
45 |
46 | ```go
47 | // expect: map[int]interface{}{1: "cvt", 2: 3.21}
48 | cvt.IntMapE(`{"1":"cvt","2":3.21}`)
49 | ```
50 |
51 | > More case see unit: `map_test.go`
52 |
53 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/_markup/render-heading.html:
--------------------------------------------------------------------------------
1 | {{- $showAnchor := (and (default true .Page.Params.GeekdocAnchor) (default true .Page.Site.Params.GeekdocAnchor)) -}}
2 |
3 |
4 |
5 | {{- if $showAnchor -}}
6 |
7 |
8 | {{ .Text | safeHTML }}
9 |
10 |
11 |
12 |
13 |
14 | {{- else -}}
15 |
16 |
17 | {{ .Text | safeHTML }}
18 |
19 |
20 | {{- end -}}
21 |
22 |
--------------------------------------------------------------------------------
/doc/content/en/type/int.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Int
3 | weight: 20
4 | ---
5 |
6 |
7 | {{< toc >}}
8 |
9 |
10 |
11 | ## Function
12 | - Int
13 | - IntE
14 | - IntP
15 | - Int8
16 | - Int8E
17 | - Int8P
18 | - Int16
19 | - Int16E
20 | - Int16P
21 | - Int32
22 | - Int32E
23 | - Int32P
24 | - Int64
25 | - Int64E
26 | - Int64P
27 | - Uint
28 | - UintE
29 | - UintP
30 | - Uint8
31 | - Uint8E
32 | - Uint8P
33 | - Uint16
34 | - Uint16E
35 | - Uint16P
36 | - Uint32
37 | - Uint32E
38 | - Uint32P
39 | - Uint64
40 | - Uint64E
41 | - Uint64P
42 |
43 | ## Examples
44 | ```go
45 | cvt.Int(int8(8)) // 8
46 | cvt.Int(int32(8)) // 8
47 | cvt.Int("-8.01") // -8
48 | cvt.Int([]byte("8.00")) // 8
49 | cvt.Int(nil) // 0
50 | cvt.IntE("8a") // 0,err
51 | cvt.IntE([]int{}) // 0,err
52 |
53 | // alias type
54 | type OrderType uint8
55 | cvt.Int(OrderType(3)) // 3
56 |
57 | var po OrderType = 3
58 | cvt.Int(&po) // 3
59 |
60 | cvt.IntP("12") // (*int)(0x140000a4180)(12)
61 | ```
62 |
63 | > More case see unit: `int_test.go`
64 |
65 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/int.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Int
3 | weight: 20
4 | ---
5 |
6 | 安全的转换数据为整型。
7 |
8 | {{< toc >}}
9 |
10 |
11 |
12 | ## 方法
13 | 支持的整型方法:
14 |
15 | - Int
16 | - IntE
17 | - IntP
18 | - Int8
19 | - Int8E
20 | - Int8P
21 | - Int16
22 | - Int16E
23 | - Int16P
24 | - Int32
25 | - Int32E
26 | - Int32P
27 | - Int64
28 | - Int64E
29 | - Int64P
30 | - Uint
31 | - UintE
32 | - UintP
33 | - Uint8
34 | - Uint8E
35 | - Uint8P
36 | - Uint16
37 | - Uint16E
38 | - Uint16P
39 | - Uint32
40 | - Uint32E
41 | - Uint32P
42 | - Uint64
43 | - Uint64E
44 | - Uint64P
45 |
46 | ## 示例
47 | ```go
48 | cvt.Int(int8(8)) // 8
49 | cvt.Int(int32(8)) // 8
50 | cvt.Int("-8.01") // -8
51 | cvt.Int([]byte("8.00")) // 8
52 | cvt.Int(nil) // 0
53 | cvt.IntE("8a") // 0,err
54 | cvt.IntE([]int{}) // 0,err
55 |
56 | // alias type
57 | type OrderType uint8
58 | cvt.Int(OrderType(3)) // 3
59 |
60 | var po OrderType = 3
61 | cvt.Int(&po) // 3
62 |
63 | cvt.IntP("12") // (*int)(0x140000a4180)(12)
64 | ```
65 |
66 | > 更多示例请看单元测试:`int_test.go`
67 |
68 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) shockerli
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/time.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Time
3 | weight: 50
4 | ---
5 |
6 |
7 | {{< toc >}}
8 |
9 | ## Time
10 |
11 | ## TimeE
12 |
13 | ```go
14 | cvt.Time("2009-11-10 23:00:00 +0000 UTC")
15 | cvt.Time("2018-10-21T23:21:29+0200")
16 | cvt.Time("10 Nov 09 23:00 UTC")
17 | cvt.Time("2009-11-10T23:00:00Z")
18 | cvt.Time("11:00PM")
19 | cvt.Time("2006-01-02")
20 | cvt.Time("2006.01.02")
21 | cvt.Time("2006/01/02")
22 | cvt.Time("2016-03-06 15:28:01")
23 | cvt.Time("2016-03-06 15:28:01.332")
24 | cvt.Time("2016-03-06 15:28:01.332901")
25 | cvt.Time("2016-03-06 15:28:01.332901345")
26 | cvt.Time("2006年01月02日 15时04分05秒")
27 | cvt.Time("Mon Jan 2 15:04:05 2006 -0700")
28 | cvt.Time(1482597504)
29 | cvt.Time(time.Duration(1482597504))
30 | cvt.Time(time.Date(2009, 2, 13, 23, 31, 30, 0, time.Local))
31 | cvt.Time(json.Number("1234567890"))
32 | cvt.Time(json.Number("2016-03-06 15:28:01"))
33 | ```
34 |
35 | ## TimeInLocation
36 | cvt.TimeInLocation("2009-02-13 23:31:30", time.FixedZone("UTC", 8*3600))
37 |
38 | ## TimeInLocationE
39 | cvt.TimeInLocationE("2009-02-13 23:31:30", time.FixedZone("UTC", 8*3600))
40 |
41 |
42 | > 更多示例请看单元测试:`time_test.go`
43 |
44 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY: check fmt lint test test-race vet test-cover-html help
2 | .DEFAULT_GOAL := help
3 |
4 | check: test-race fmt vet lint ## Run tests and linters
5 |
6 | test: ## Run tests
7 | go test ./...
8 |
9 | test-race: ## Run tests with race detector
10 | go test -race ./...
11 |
12 | fmt: ## Run gofmt linter
13 | @for d in `go list` ; do \
14 | if [ "`gofmt -l -s $$GOPATH/src/$$d | tee /dev/stderr`" ]; then \
15 | echo "^ improperly formatted go files" && echo && exit 1; \
16 | fi \
17 | done
18 |
19 | lint: ## Run golint linter
20 | @for d in `go list` ; do \
21 | if [ "`golint $$d | tee /dev/stderr`" ]; then \
22 | echo "^ golint errors!" && echo && exit 1; \
23 | fi \
24 | done
25 |
26 | vet: ## Run go vet linter
27 | @if [ "`go vet | tee /dev/stderr`" ]; then \
28 | echo "^ go vet errors!" && echo && exit 1; \
29 | fi
30 |
31 | test-cover-html: ## Generate test coverage report
32 | go test -coverprofile=coverage.out -covermode=count
33 | go tool cover -func=coverage.out
34 |
35 | help:
36 | @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
37 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/terms.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 | {{ range .Paginator.Pages.ByTitle }}
3 |
4 |
9 |
10 |
11 |
12 | {{ $pageCount := len .Pages }}
13 |
14 |
15 | {{ i18n "posts_count" $pageCount }}
16 |
17 |
18 |
19 |
20 |
21 |
22 | {{ $latet := index .Pages.ByDate 0 }}
23 | {{ with $latet }}
24 | {{ partial "utils/title" . }}
25 | {{ end }}
26 |
27 |
28 |
29 |
30 | {{ end }}
31 | {{ end }}
32 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Robert Kaussow
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is furnished
10 | to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice (including the next
13 | paragraph) shall be included in all copies or substantial portions of the
14 | Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
19 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
21 | OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/i18n/zh-cn.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | edit_page: 编辑页面
3 |
4 | nav_navigation: 导航
5 | nav_tags: 标签
6 | nav_more: 更多
7 | nav_top: 回到顶部
8 |
9 | form_placeholder_search: 搜索
10 |
11 | error_page_title: 迷路了? 不用担心
12 | error_message_title: 迷路了?
13 | error_message_code: 错误 404
14 | error_message_text: >
15 | 好像找不到你要找的东西。 别担心,我们可以
16 | 带您回到主页 。
17 |
18 | button_toggle_dark: 切换暗/亮/自动模式
19 | button_nav_open: 打开导航
20 | button_nav_close: 关闭导航
21 | button_menu_open: 打开菜单栏
22 | button_menu_close: 关闭菜单栏
23 | button_homepage: 返回首页
24 |
25 | title_anchor_prefix: "锚定到:"
26 |
27 | posts_read_more: 阅读全文
28 | posts_read_time:
29 | one: "一分钟阅读时间"
30 | other: "{{ . }} 分钟阅读时间"
31 | posts_update_prefix: 更新时间
32 | posts_count:
33 | one: 一篇文章
34 | other: "{{ . }} 个帖子"
35 | posts_tagged_with: 所有带有“{{ . }}”标签的帖子。
36 |
37 | footer_build_with: >
38 |
39 |
40 | footer_legal_notice: "法律声明"
41 | footer_privacy_policy: "隐私政策"
42 | footer_content_license_prefix: >
43 | 内容许可证
44 |
45 | language_switch_no_tranlation_prefix: "页面未翻译:"
46 |
47 | propertylist_required: 需要
48 | propertylist_optional: 可选
49 | propertylist_default: 默认值
50 |
--------------------------------------------------------------------------------
/doc/content/en/type/string.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: String
3 | weight: 40
4 | ---
5 |
6 |
7 | {{< toc >}}
8 |
9 |
10 |
11 | ## Function
12 | - String
13 | - StringE
14 | - StringP
15 |
16 | ## Examples
17 | ```go
18 | cvt.String(uint(8)) // "8"
19 | cvt.String(float32(8.31)) // "8.31"
20 | cvt.String(true) // "true"
21 | cvt.String([]byte("-8.01")) // "-8.01"
22 | cvt.String(nil) // ""
23 |
24 | cvt.String(errors.New("error info")) // "error info"
25 | cvt.String(time.Friday) // "Friday"
26 | cvt.String(big.NewInt(123)) // "123"
27 | cvt.String(template.URL("https://host.foo")) // "https://host.foo"
28 | cvt.String(template.HTML("")) // ""
29 | cvt.String(json.Number("12.34")) // "12.34"
30 |
31 | // custom type
32 | type TestMarshalJSON struct{}
33 |
34 | func (TestMarshalJSON) MarshalJSON() ([]byte, error) {
35 | return []byte("custom marshal"), nil
36 | }
37 | cvt.String(TestMarshalJSON{}) // "custom marshal"
38 | cvt.String(&TestMarshalJSON{}) // "custom marshal"
39 |
40 | cvt.StringP(8.31) // (*string)(0x14000110320)((len=3) "123")
41 | ```
42 |
43 | > More case see unit: `string_test.go`
44 |
45 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/string.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: String
3 | weight: 40
4 | ---
5 |
6 | 安全的转换数据为字符串。
7 |
8 | {{< toc >}}
9 |
10 |
11 |
12 | ## 方法
13 | - String
14 | - StringE
15 | - StringP
16 |
17 | ## 示例
18 | ```go
19 | cvt.String(uint(8)) // "8"
20 | cvt.String(float32(8.31)) // "8.31"
21 | cvt.String(true) // "true"
22 | cvt.String([]byte("-8.01")) // "-8.01"
23 | cvt.String(nil) // ""
24 |
25 | cvt.String(errors.New("error info")) // "error info"
26 | cvt.String(time.Friday) // "Friday"
27 | cvt.String(big.NewInt(123)) // "123"
28 | cvt.String(template.URL("https://host.foo")) // "https://host.foo"
29 | cvt.String(template.HTML("")) // ""
30 | cvt.String(json.Number("12.34")) // "12.34"
31 |
32 | // custom type
33 | type TestMarshalJSON struct{}
34 |
35 | func (TestMarshalJSON) MarshalJSON() ([]byte, error) {
36 | return []byte("custom marshal"), nil
37 | }
38 | cvt.String(TestMarshalJSON{}) // "custom marshal"
39 | cvt.String(&TestMarshalJSON{}) // "custom marshal"
40 |
41 | cvt.StringP(8.31) // (*string)(0x14000110320)((len=3) "123")
42 | ```
43 |
44 | > 更多示例请看单元测试:`string_test.go`
45 |
46 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/mobile-c0e18b0e.min.css:
--------------------------------------------------------------------------------
1 | @media screen and (max-width: 39rem){.gdoc-nav{margin-left:-16rem;font-size:16px}.gdoc-nav__control{display:inline-block}.gdoc-header svg.gdoc-icon{width:1.5rem;height:1.5rem}.gdoc-brand{font-size:1.5rem;line-height:1.5rem}.gdoc-brand__img{display:none}.gdoc-menu-header__items{display:none}.gdoc-menu-header__control,.gdoc-menu-header__home{display:flex}.gdoc-error{padding:6rem 1rem}.gdoc-error svg.gdoc-icon{width:6rem;height:6rem}.gdoc-error__message{padding-left:2rem}.gdoc-error__line{padding:.25rem 0}.gdoc-error__title{font-size:2rem}.gdoc-page__header .breadcrumb,.hidden-mobile{display:none}.flex-mobile-column{flex-direction:column}.flex-mobile-column.gdoc-columns{margin:2rem 0}.flex-mobile-column .gdoc-columns__content{min-width:auto;margin:0}#menu-control:checked~main .gdoc-nav nav,#menu-control:checked~main .gdoc-page{transform:translateX(16rem)}#menu-control:checked~main .gdoc-page{opacity:.25}#menu-control:checked~.gdoc-header .gdoc-nav__control svg.gdoc-icon.gdoc_menu{display:none}#menu-control:checked~.gdoc-header .gdoc-nav__control svg.gdoc-icon.gdoc_arrow_back{display:inline-block}#menu-header-control:checked~.gdoc-header .gdoc-brand{display:none}#menu-header-control:checked~.gdoc-header .gdoc-menu-header__items{display:flex}#menu-header-control:checked~.gdoc-header .gdoc-menu-header__control svg.gdoc-icon.gdoc_keyboard_arrow_left{display:none}}
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ partial "head/meta" . }}
5 | {{ i18n "error_page_title" }}
6 |
7 | {{ partial "head/favicons" . }}
8 | {{ partial "head/others" . }}
9 |
10 |
11 |
12 | {{ partial "svg-icon-symbols" . }}
13 |
14 |
15 |
16 |
17 |
18 | {{ partial "site-header" (dict "Root" . "MenuEnabled" false) }}
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
{{ i18n "error_message_title" }}
28 |
{{ i18n "error_message_code" }}
29 |
30 | {{ i18n "error_message_text" .Site.BaseURL | safeHTML }}
31 |
32 |
33 |
34 |
35 |
36 | {{ partial "site-footer" . }}
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/i18n/ja.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | edit_page: ページの編集
3 |
4 | nav_navigation: ナビゲーション
5 | nav_tags: タグ
6 | nav_more: さらに
7 | nav_top: トップへ戻る
8 |
9 | form_placeholder_search: 検索
10 |
11 | error_page_title: お困りですか?ご心配なく
12 | error_message_title: お困りですか?
13 | error_message_code: 404 エラー
14 | error_message_text: >
15 | お探しのものが見つからないようです。トップページ
16 | へ戻ることができるので、ご安心ください。
17 |
18 | button_toggle_dark: モードの切替 ダーク/ライト/自動
19 | button_nav_open: ナビゲーションを開く
20 | button_nav_close: ナビゲーションを閉じる
21 | button_menu_open: メニューバーを開く
22 | button_menu_close: メニューバーを閉じる
23 | button_homepage: トップページへ戻る
24 |
25 | title_anchor_prefix: "アンカー先:"
26 |
27 | posts_read_more: 全投稿を閲覧
28 | posts_read_time:
29 | one: "読むのに 1 分かかります"
30 | other: "読むのに要する時間 {{ . } (分)}"
31 | posts_update_prefix: 更新時刻
32 | posts_count:
33 | one: "一件の投稿"
34 | other: "{{ . }} 件の投稿"
35 | posts_tagged_with: "'{{ . }}'のタグが付いた記事全部"
36 |
37 | footer_build_with: >
38 | でビルドしています。
39 |
40 | footer_legal_notice: 法的な告知事項
41 | footer_privacy_policy: プライバシーポリシー
42 | footer_content_license_prefix: >
43 | 提供するコンテンツのライセンス
44 |
45 | language_switch_no_tranlation_prefix: "未翻訳のページ:"
46 |
47 | propertylist_required: 必須
48 | propertylist_optional: 任意
49 | propertylist_default: 既定値
50 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/posts/list.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 | {{ range .Paginator.Pages }}
3 |
4 |
9 |
12 |
24 |
25 |
30 |
31 | {{ end }}
32 | {{ end }}
33 |
34 | {{ define "post-tag" }}
35 |
36 |
37 |
42 | {{ .name }}
43 |
44 |
45 |
46 | {{ end }}
47 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/taxonomy.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 | {{ range .Paginator.Pages }}
3 |
4 |
9 |
10 |
13 |
14 |
26 |
27 |
32 |
33 | {{ end }}
34 | {{ end }}
35 |
36 | {{ define "post-tag" }}
37 |
38 |
39 |
44 | {{ .name }}
45 |
46 |
47 |
48 | {{ end }}
49 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/menu-extra.html:
--------------------------------------------------------------------------------
1 | {{ $current := .current }}
2 | {{ template "menu-extra" dict "sect" .source "current" $current "site" $current.Site "target" .target }}
3 |
4 |
5 |
6 | {{ define "menu-extra" }}
7 | {{ $current := .current }}
8 | {{ $site := .site }}
9 | {{ $target := .target }}
10 | {{ $sect := .sect }}
11 |
12 | {{ range sort (default (seq 0) $sect) "weight" }}
13 | {{ if isset . "ref" }}
14 | {{ $this := $site.GetPage .ref }}
15 | {{ $isCurrent := eq $current $this }}
16 | {{ $icon := default false .icon }}
17 |
18 | {{ $name := .name }}
19 | {{ if reflect.IsMap .name }}
20 | {{ $name = (index .name $site.Language.Lang) }}
21 | {{ end }}
22 |
23 | {{ if not .icon }}
24 | {{ errorf "Missing 'icon' attribute in data file for '%s' menu item '%s'" $target $name }}
25 | {{ end }}
26 |
27 | {{ if eq $target "header" }}
28 |
29 |
42 |
43 | {{ end }}
44 | {{ end }}
45 | {{ end }}
46 | {{ end }}
47 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/i18n/en.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | edit_page: Edit page
3 |
4 | nav_navigation: Navigation
5 | nav_tags: Tags
6 | nav_more: More
7 | nav_top: Back to top
8 |
9 | form_placeholder_search: Search
10 |
11 | error_page_title: Lost? Don't worry
12 | error_message_title: Lost?
13 | error_message_code: Error 404
14 | error_message_text: >
15 | Seems like what you are looking for can't be found. Don't worry, we can
16 | bring you back to the homepage .
17 |
18 | button_toggle_dark: Toggle Dark/Light/Auto mode
19 | button_nav_open: Open Navigation
20 | button_nav_close: Close Navigation
21 | button_menu_open: Open Menu Bar
22 | button_menu_close: Close Menu Bar
23 | button_homepage: Back to homepage
24 |
25 | title_anchor_prefix: "Anchor to:"
26 |
27 | posts_read_more: Read full post
28 | posts_read_time:
29 | one: "One minute to read"
30 | other: "{{ . }} minutes to read"
31 | posts_update_prefix: Updated on
32 | posts_count:
33 | one: "One post"
34 | other: "{{ . }} posts"
35 | posts_tagged_with: All posts tagged with '{{ . }}'
36 |
37 | footer_build_with: >
38 |
39 |
40 | footer_legal_notice: Legal Notice
41 | footer_privacy_policy: Privacy Policy
42 | footer_content_license_prefix: >
43 | Content licensed under
44 |
45 | language_switch_no_tranlation_prefix: "Page not translated:"
46 |
47 | propertylist_required: required
48 | propertylist_optional: optional
49 | propertylist_default: default
50 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "geekdoc",
3 | "short_name": "geekdoc",
4 | "description": "Hugo theme made for documentation",
5 | "dir": "auto",
6 | "lang": "en-US",
7 | "display": "standalone",
8 | "orientation": "any",
9 | "start_url": "/?homescreen=1",
10 | "background_color": "#2f333e",
11 | "theme_color": "#2f333e",
12 | "icons": [
13 | {
14 | "src": "android-chrome-36x36.png",
15 | "sizes": "36x36",
16 | "type": "image/png"
17 | },
18 | {
19 | "src": "android-chrome-48x48.png",
20 | "sizes": "48x48",
21 | "type": "image/png"
22 | },
23 | {
24 | "src": "android-chrome-72x72.png",
25 | "sizes": "72x72",
26 | "type": "image/png"
27 | },
28 | {
29 | "src": "android-chrome-96x96.png",
30 | "sizes": "96x96",
31 | "type": "image/png"
32 | },
33 | {
34 | "src": "android-chrome-144x144.png",
35 | "sizes": "144x144",
36 | "type": "image/png"
37 | },
38 | {
39 | "src": "android-chrome-192x192.png",
40 | "sizes": "192x192",
41 | "type": "image/png"
42 | },
43 | {
44 | "src": "android-chrome-256x256.png",
45 | "sizes": "256x256",
46 | "type": "image/png"
47 | },
48 | {
49 | "src": "android-chrome-384x384.png",
50 | "sizes": "384x384",
51 | "type": "image/png"
52 | },
53 | {
54 | "src": "android-chrome-512x512.png",
55 | "sizes": "512x512",
56 | "type": "image/png"
57 | }
58 | ]
59 | }
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/menu.html:
--------------------------------------------------------------------------------
1 |
2 | {{ partial "search" . }}
3 |
4 |
5 |
6 | {{ i18n "nav_navigation" }}
7 | {{ if .Site.Params.GeekdocMenuBundle }}
8 | {{ partial "menu-bundle" (dict "current" . "source" .Site.Data.menu.main.main) }}
9 | {{ else }}
10 | {{ partial "menu-filetree" . }}
11 | {{ end }}
12 |
13 |
14 | {{ if and (in (slice "posts" "tags") .Section) (default false .Site.Params.GeekdocTagsToMenu) }}
15 |
35 | {{ end }}
36 |
37 |
38 |
39 | {{ if .Site.Data.menu.more.more }}
40 | {{ i18n "nav_more" }}
41 | {{ partial "menu-bundle" (dict "current" . "source" .Site.Data.menu.more.more) }}
42 | {{ end }}
43 |
44 |
45 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/toc-tree.html:
--------------------------------------------------------------------------------
1 | {{- $tocLevels := default (default 6 .Site.Params.GeekdocToC) .Page.Params.GeekdocToC }}
2 |
3 | {{- if $tocLevels }}
4 |
5 | {{ template "toc-tree" dict "sect" .Page.Pages }}
6 |
7 | {{- end }}
8 |
9 |
10 |
11 | {{- define "toc-tree" }}
12 |
13 | {{- range .sect.GroupBy "Weight" }}
14 | {{- range .ByTitle }}
15 | {{- if or (not .Params.GeekdocHidden) (not (default true .Params.GeekdocHiddenTocTree)) }}
16 |
17 | {{- if or .Content .Params.GeekdocFlatSection }}
18 |
19 |
20 | {{- partial "utils/title" . }}{{ with .Params.GeekdocDescription }}:{{ end }}
21 |
22 | {{- with .Params.GeekdocDescription }}{{ . }}{{ end }}
23 |
24 | {{- else -}}
25 |
26 | {{- partial "utils/title" . }}{{ with .Params.GeekdocDescription }}: {{ . }}{{ end }}
27 |
28 | {{- end -}}
29 |
30 | {{- $numberOfPages := (add (len .Pages) (len .Sections)) }}
31 | {{- if and (ne $numberOfPages 0) (not .Params.GeekdocFlatSection) }}
32 | {{- template "toc-tree" dict "sect" .Pages }}
33 | {{- end }}
34 |
35 | {{- end }}
36 | {{- end }}
37 | {{- end }}
38 |
39 | {{- end }}
40 |
--------------------------------------------------------------------------------
/doc/content/en/type/others.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Others
3 | weight: 80
4 | ---
5 |
6 |
7 | {{< toc >}}
8 |
9 | ## Field
10 | Reference method `FieldE`.
11 |
12 | ## FieldE
13 | Return the field value from map/struct, `interface{}`.
14 |
15 | ```go
16 | // map
17 | cvt.FieldE(map[int]interface{}{123: "112233"}, "123") // "112233"
18 | cvt.FieldE(map[string]interface{}{"123": "112233"}, "123") // "112233"
19 |
20 | // struct
21 | cvt.FieldE(struct{
22 | A string
23 | B int
24 | }{"Hello", 18}, "A") // "Hello"
25 | cvt.FieldE(struct{
26 | A string
27 | B int
28 | }{"Hello", 18}, "B") // 18
29 | ```
30 |
31 | Combine with other methods:
32 |
33 | ```go
34 | cvt.Int(cvt.Field(map[int]interface{}{123: "112233"}, 123)) // 112233
35 | ```
36 |
37 | ## Len
38 | return size of string, slice, array or map.
39 |
40 | ```go
41 | cvt.Len("Hello") // 5
42 | cvt.Len([]int{1, 2, 3}) // 3
43 | cvt.Len([]interface{}{1, "2", 3.0}}) // 3
44 | cvt.Len(map[int]interface{}{1: 1, 2: 2}) // 2
45 | ```
46 |
47 | ## IsEmpty
48 | checks value for empty state.
49 |
50 | ```go
51 | cvt.IsEmpty("") // true
52 | cvt.IsEmpty("123") // false
53 | cvt.IsEmpty(nil) // true
54 | cvt.IsEmpty(true) // false
55 | cvt.IsEmpty(false) // true
56 | cvt.IsEmpty(0) // true
57 | cvt.IsEmpty(1) // false
58 | cvt.IsEmpty(180) // false
59 | cvt.IsEmpty(1.23) // false
60 | cvt.IsEmpty([]bool{}) // true
61 | cvt.IsEmpty([]int{1, 2}) // false
62 | cvt.IsEmpty(map[int]interface{}(nil)) // true
63 | cvt.IsEmpty(map[string]string{"1": "1", "2": "2"}) // false
64 | ```
65 |
66 | > More case see unit: `cvte_test.go`
67 |
68 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/others.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Others
3 | weight: 80
4 | ---
5 |
6 |
7 | {{< toc >}}
8 |
9 |
10 | ## Field
11 | Reference method `FieldE`.
12 |
13 | ## FieldE
14 | Return the field value from map/struct, `interface{}`.
15 |
16 | ```go
17 | // map
18 | cvt.FieldE(map[int]interface{}{123: "112233"}, "123") // "112233"
19 | cvt.FieldE(map[string]interface{}{"123": "112233"}, "123") // "112233"
20 |
21 | // struct
22 | cvt.FieldE(struct{
23 | A string
24 | B int
25 | }{"Hello", 18}, "A") // "Hello"
26 | cvt.FieldE(struct{
27 | A string
28 | B int
29 | }{"Hello", 18}, "B") // 18
30 | ```
31 |
32 | Combine with other methods:
33 |
34 | ```go
35 | cvt.Int(cvt.Field(map[int]interface{}{123: "112233"}, 123)) // 112233
36 | ```
37 |
38 | ## Len
39 | return size of string, slice, array or map.
40 |
41 | ```go
42 | cvt.Len("Hello") // 5
43 | cvt.Len([]int{1, 2, 3}) // 3
44 | cvt.Len([]interface{}{1, "2", 3.0}}) // 3
45 | cvt.Len(map[int]interface{}{1: 1, 2: 2}) // 2
46 | ```
47 |
48 | ## IsEmpty
49 | checks value for empty state.
50 |
51 | ```go
52 | cvt.IsEmpty("") // true
53 | cvt.IsEmpty("123") // false
54 | cvt.IsEmpty(nil) // true
55 | cvt.IsEmpty(true) // false
56 | cvt.IsEmpty(false) // true
57 | cvt.IsEmpty(0) // true
58 | cvt.IsEmpty(1) // false
59 | cvt.IsEmpty(180) // false
60 | cvt.IsEmpty(1.23) // false
61 | cvt.IsEmpty([]bool{}) // true
62 | cvt.IsEmpty([]int{1, 2}) // false
63 | cvt.IsEmpty(map[int]interface{}(nil)) // true
64 | cvt.IsEmpty(map[string]string{"1": "1", "2": "2"}) // false
65 | ```
66 |
67 |
68 | > 更多示例请看单元测试:`cvte_test.go`
69 |
70 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/usage/getting-started.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 快速上手
3 | weight: -20
4 | ---
5 |
6 | 简单、安全、高效的转换任意数据类型的 Go 语言工具包,支持自定义类型、提取结构体字段和值。
7 |
8 |
9 | {{< hint type=warning >}}
10 | **文档说明**\
11 | `__()`、`__P()` 均是以其对应的 `__E()` 为基础的便捷方法,故其使用方法及支持的类型请参考 `__E()` 的文档,大部分此类便利方法均不再详细阐述。
12 | {{< /hint >}}
13 |
14 |
15 |
16 |
17 | {{< toc >}}
18 |
19 | ## 环境
20 | - Go >= 1.13
21 |
22 |
23 | ## 安装
24 | ```go
25 | go get -u github.com/shockerli/cvt
26 | ```
27 |
28 | ## 引入
29 | ```go
30 | import "github.com/shockerli/cvt"
31 | ```
32 |
33 |
34 | ## 使用
35 | ### 支持 `error`
36 |
37 | > 以 `E` 结尾的方法 `__E()`: 当转换失败时会返回错误
38 |
39 | ```go
40 | cvt.IntE("12") // 12, nil
41 | cvt.Float64E("12.34") // 12.34, nil
42 | cvt.StringE(12.34) // "12.34", nil
43 | cvt.BoolE("false") // false, nil
44 | ```
45 |
46 | ### 自定义类型、指针类型
47 |
48 | > 自动解引用,并找到基本类型,完全支持自定义类型的转换
49 |
50 | ```go
51 | type Name string
52 |
53 | var name Name = "jioby"
54 |
55 | cvt.StringE(name) // jioby, nil
56 | cvt.StringE(&name) // jioby, nil
57 | ```
58 |
59 | ### 忽略 `error`
60 |
61 | > 名称不以 `E` 结尾的方法,如果转换失败,不会返回错误,会返回零值
62 |
63 | ```go
64 | cvt.Int("12") // 12(success)
65 | cvt.Int(struct{}{}) // 0(failed)
66 | ```
67 |
68 | ### 默认值
69 |
70 | > 如果转换失败,返回默认值
71 |
72 | ```go
73 | cvt.Int(struct{}{}, 12) // 12
74 | cvt.Float("hello", 12.34) // 12.34
75 | ```
76 |
77 | ### 数据指针
78 | > 以 `P` 结尾的方法 `__P`,返回转换后数据的指针地址
79 |
80 | ```go
81 | cvt.BoolP("true") // (*bool)(0x14000126180)(true)
82 | ```
83 |
84 |
85 | ### 更多示例
86 |
87 | > 上千个单元测试用例,覆盖率近100%,所有示例可通过单元测试了解:`*_test.go`
88 |
89 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/i18n/de.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | edit_page: Seite bearbeiten
3 |
4 | nav_navigation: Navigation
5 | nav_tags: Tags
6 | nav_more: Weitere
7 | nav_top: Nach oben
8 |
9 | form_placeholder_search: Suchen
10 |
11 | error_page_title: Verlaufen? Keine Sorge
12 | error_message_title: Verlaufen?
13 | error_message_code: Fehler 404
14 | error_message_text: >
15 | Wir können die Seite nach der Du gesucht hast leider nicht finden. Keine Sorge,
16 | wir bringen Dich zurück zur Startseite .
17 |
18 | button_toggle_dark: Wechsel zwischen Dunkel/Hell/Auto Modus
19 | button_nav_open: Navigation öffnen
20 | button_nav_close: Navigation schließen
21 | button_menu_open: Menüband öffnen
22 | button_menu_close: Menüband schließen
23 | button_homepage: Zurück zur Startseite
24 |
25 | title_anchor_prefix: "Link zu:"
26 |
27 | posts_read_more: Ganzen Artikel lesen
28 | posts_read_time:
29 | one: "Eine Minute Lesedauer"
30 | other: "{{ . }} Minuten Lesedauer"
31 | posts_update_prefix: Aktualisiert am
32 | posts_count:
33 | one: "Ein Artikel"
34 | other: "{{ . }} Artikel"
35 | posts_tagged_with: Alle Artikel mit dem Tag '{{ . }}'
36 |
37 | footer_build_with: >
38 | Entwickelt mit und
39 |
40 | footer_legal_notice: Impressum
41 | footer_privacy_policy: Datenschutzerklärung
42 | footer_content_license_prefix: >
43 | Inhalt lizensiert unter
44 |
45 | language_switch_no_tranlation_prefix: "Seite nicht übersetzt:"
46 |
47 | propertylist_required: erforderlich
48 | propertylist_optional: optional
49 | propertylist_default: Standardwert
50 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/posts/metadata.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ if .Lastmod.After (.Date.AddDate 0 0 1) }}
6 | {{ i18n "posts_update_prefix" }}
7 | {{ end }}
8 | {{ .Lastmod.Format "Jan 2, 2006" }}
9 |
10 |
11 |
12 |
13 |
14 |
15 | {{ i18n "posts_read_time" .ReadingTime }}
16 |
17 |
18 | {{ $tc := 0 }}
19 | {{ with .Params.tags }}
20 | {{ range sort . }}
21 | {{ $name := . }}
22 | {{ with $.Site.GetPage (printf "/tags/%s" $name | urlize) }}
23 | {{ if eq $tc 0 }}
24 |
25 |
26 | {{ template "post-tag" dict "name" $name "page" . }}
27 |
28 | {{ else }}
29 |
30 | {{ template "post-tag" dict "name" $name "page" . }}
31 |
32 | {{ end }}
33 | {{ end }}
34 | {{ $tc = (add $tc 1) }}
35 | {{ end }}
36 | {{ end }}
37 |
38 | {{ define "post-tag" }}
39 |
40 |
45 | {{ .name }}
46 |
47 |
48 | {{ end }}
49 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/i18n/it.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | edit_page: Modifica la pagina
3 |
4 | nav_navigation: Navigazione
5 | nav_tags: Etichette
6 | nav_more: Altro
7 | nav_top: Torna su
8 |
9 | form_placeholder_search: Cerca
10 |
11 | error_page_title: Perso? Non ti preoccupare
12 | error_message_title: Perso?
13 | error_message_code: Errore 404
14 | error_message_text: >
15 | Sembra che non sia possibile trovare quello che stavi cercando. Non ti preoccupare,
16 | possiamo riportarti alla pagina iniziale .
17 |
18 | button_toggle_dark: Seleziona il tema Chiaro/Scuro/Automatico
19 | button_nav_open: Apri la Navigazione
20 | button_nav_close: Chiudi la Navigazione
21 | button_menu_open: Apri la Barra del Menu
22 | button_menu_close: Chiudi la Barra del Menu
23 | button_homepage: Torna alla pagina iniziale
24 |
25 | title_anchor_prefix: "Ancora a:"
26 |
27 | posts_read_more: Leggi tutto il post
28 | posts_read_time:
29 | one: "Tempo di lettura: un minuto"
30 | other: "Tempo di lettura: {{ . }} minuti"
31 | posts_update_prefix: Aggiornato il
32 | posts_count:
33 | one: "Un post"
34 | other: "{{ . }} post"
35 | posts_tagged_with: Tutti i post etichettati con '{{ . }}'
36 |
37 | footer_build_with: >
38 | Realizzato con e
39 |
40 | footer_legal_notice: Avviso Legale
41 | footer_privacy_policy: Politica sulla Privacy
42 | footer_content_license_prefix: >
43 | Contenuto sotto licenza
44 |
45 | language_switch_no_tranlation_prefix: "Pagina non tradotta:"
46 |
47 | propertylist_required: richiesto
48 | propertylist_optional: opzionale
49 | propertylist_default: valore predefinito
50 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/bool.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Bool
3 | weight: 10
4 | ---
5 |
6 | 安全的转换数据为布尔类型。
7 |
8 | {{< toc >}}
9 |
10 |
11 | ## Bool
12 | 转换任意类型数据为布尔类型,忽略错误,支持设置默认值(默认 `false`)。
13 |
14 | `Bool` 本质是调用 `BoolE` 方法,如果遇到 `error` 则返回默认值。
15 |
16 | 该方法永远不会报错。
17 |
18 | ```go
19 | cvt.Bool(0) // false
20 | cvt.Bool(nil) // false
21 | cvt.Bool("0") // false
22 | cvt.Bool("false") // false
23 | cvt.Bool([]int{}) // false
24 |
25 | cvt.Bool(true) // true
26 | cvt.Bool("true") // true
27 | cvt.Bool([]int{1, 2}) // true
28 | cvt.Bool([]byte("true")) // true
29 | ```
30 |
31 | ## BoolE
32 | 转换任意类型数据为布尔类型,不支持的转换时会返回 `error` 错误。
33 |
34 | ```go
35 | cvt.BoolE(0) // false,nil
36 | cvt.BoolE(nil) // false,nil
37 | cvt.BoolE("0") // false,nil
38 | cvt.BoolE("false") // false,nil
39 | cvt.BoolE([]int{}) // false,nil
40 |
41 | cvt.BoolE(true) // true,nil
42 | cvt.BoolE("true") // true,nil
43 | cvt.BoolE([]int{1, 2}) // true,nil
44 | cvt.BoolE([]byte("true")) // true,nil
45 | ```
46 |
47 | ## BoolP
48 | 转换任意类型数据为布尔类型的**指针地址**,忽略错误,支持设置默认值(默认 `false`)。
49 |
50 | `BoolP` 本质是调用 `Bool` 方法,并返回其指针地址,用法与 `Bool` 完全一致。
51 |
52 | ```go
53 | cvt.BoolP("true") // (*bool)(0x14000126180)(true)
54 | ```
55 |
56 |
57 | ## 规则
58 | ### nil
59 | 返回 `false`
60 |
61 | ### 布尔
62 | 原值
63 |
64 | ### 数字
65 | > 整型、浮点型、及其衍生类型,比如 `int64` 的衍生类型之一 `time.Duration`
66 |
67 | 判定规则:`是否等于 0`,只要不等于零即为 `true`;否则为 `false`。
68 |
69 | ### 字符串
70 | > `string`、`[]byte`、及其衍生类型
71 |
72 | ### json.Number
73 | 其值如果是数字字符串,则可转换为 `float64` 再判定是否等于零;如果非数字字符串,则报错。
74 |
75 | ### Array/Slice/Map
76 | 如果其元素个数(len)大于零,即返回 `true`;否则返回 `false`。
77 |
78 | ### 其他
79 | 不在上述已列类型中,即表示不支持,直接报错不支持。
80 |
81 |
82 | ## 更多示例
83 | 更多示例请看单元测试文件:`bool_test.go`
84 |
85 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/_default/baseof.html:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 | {{ partial "head/meta" . }}
9 |
10 | {{- if eq .Kind "home" -}}
11 | {{ .Site.Title }}
12 | {{- else -}}
13 | {{ printf "%s | %s" (partial "utils/title" .) .Site.Title }}
14 | {{- end -}}
15 |
16 |
17 | {{ partial "head/favicons" . }}
18 | {{ partial "head/rel-me" . }}
19 | {{ partial "head/microformats" . }}
20 | {{ partial "head/others" . }}
21 | {{ partial "head/custom" . }}
22 |
23 |
24 |
25 | {{ partial "svg-icon-symbols" . }}
26 |
27 |
28 |
31 |
32 |
33 | {{ $navEnabled := default true .Page.Params.GeekdocNav }}
34 | {{ partial "site-header" (dict "Root" . "MenuEnabled" $navEnabled) }}
35 |
36 |
37 |
38 | {{ if $navEnabled }}
39 |
40 | {{ partial "menu" . }}
41 |
42 | {{ end }}
43 |
44 |
45 |
46 | {{ template "main" . }}
47 |
48 |
49 |
52 |
53 |
54 |
55 | {{ partial "site-footer" . }}
56 |
57 |
58 | {{ partial "foot" . }}
59 |
60 |
61 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/language.html:
--------------------------------------------------------------------------------
1 | {{ if .Site.IsMultiLingual }}
2 |
3 |
4 |
5 | {{ range .Site.Languages }}
6 | {{ if eq . $.Site.Language }}
7 |
8 |
9 | {{ .Lang | upper }}
10 |
11 | {{ end }}
12 | {{ end }}
13 |
14 |
15 |
48 |
49 |
50 |
51 | {{ end }}
52 |
--------------------------------------------------------------------------------
/doc/content/en/usage/getting-started.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Getting Started
3 | weight: -20
4 | ---
5 |
6 | Simple, safe conversion of any type, including indirect/custom types.
7 |
8 |
9 | {{< hint type=warning >}}
10 | **Document statement**\
11 | `__()` and `__P()` are convenient method is based on `__E()`, so the method of use and the type of support please reference ` __E () ` document.
12 | {{< /hint >}}
13 |
14 |
15 |
16 | {{< toc >}}
17 |
18 | ## Requirements
19 | - Go >= 1.13
20 |
21 |
22 | ## Install
23 | ```go
24 | go get -u github.com/shockerli/cvt
25 | ```
26 |
27 | ## Import
28 | ```go
29 | import "github.com/shockerli/cvt"
30 | ```
31 |
32 |
33 | ## Usage
34 |
35 | ### with `error`
36 |
37 | > Method `__E()`: expect handle error, while unable to convert
38 |
39 | ```go
40 | cvt.IntE("12") // 12, nil
41 | cvt.Float64E("12.34") // 12.34, nil
42 | cvt.StringE(12.34) // "12.34", nil
43 | cvt.BoolE("false") // false, nil
44 | ```
45 |
46 | ### custom type and pointers
47 |
48 | > dereferencing pointer and reach the original type
49 |
50 | ```go
51 | type Name string
52 |
53 | var name Name = "jioby"
54 |
55 | cvt.StringE(name) // jioby, nil
56 | cvt.StringE(&name) // jioby, nil
57 | ```
58 |
59 | ### ignore `error`
60 |
61 | > Method `__()`: ignore error, while convert failed, will return the zero value of type
62 |
63 | ```go
64 | cvt.Int("12") // 12(success)
65 | cvt.Int(struct{}{}) // 0(failed)
66 | ```
67 |
68 | ### with default
69 |
70 | > return the default value, while convert failed
71 |
72 | ```go
73 | cvt.Int(struct{}{}, 12) // 12
74 | cvt.Float("hello", 12.34) // 12.34
75 | ```
76 |
77 | ### Pointer
78 | > Method `__P`, return the pointer of converted data
79 |
80 | ```go
81 | cvt.BoolP("true") // (*bool)(0x14000126180)(true)
82 | ```
83 |
84 | ### more
85 |
86 | > 1000+ unit test cases, for more examples, see `*_test.go`
87 |
88 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/site-footer.html:
--------------------------------------------------------------------------------
1 |
46 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/propertylist.html:
--------------------------------------------------------------------------------
1 | {{- $name := .Get "name" -}}
2 |
3 | {{- if .Site.Data.properties }}
4 |
5 | {{- with (index .Site.Data.properties (split $name ".")) }}
6 | {{- range $key, $value := .properties }}
7 |
8 | {{ $key }}
9 | {{- if $value.required }}
10 | {{ i18n "propertylist_required" | lower }}
11 | {{ else }}
12 | {{ i18n "propertylist_optional" | lower }}
13 | {{- end }}
14 | {{- with $value.type }}
15 | {{ . }}
16 | {{- end }}
17 |
18 | {{- with $value.tags }}
19 | {{- $tags := . }}
20 | {{- if reflect.IsMap $tags }}
21 | {{- $tags = (index $tags $.Site.Language.Lang) }}
22 | {{- end }}
23 | {{- range $tags }}
24 | {{ . }}
25 | {{- end }}
26 | {{- end }}
27 |
28 |
29 |
30 | {{- with $value.description }}
31 | {{- $desc := . }}
32 | {{- if reflect.IsMap $desc }}
33 | {{- $desc = (index $desc $.Site.Language.Lang) }}
34 | {{- end }}
35 |
36 | {{ $desc | $.Page.RenderString }}
37 | {{ end }}
38 |
39 |
40 | {{- with default "none" ($value.defaultValue | string) }}
41 | {{ i18n "propertylist_default" | title }}:
42 | {{ . }}
43 | {{- end }}
44 |
45 |
46 | {{- end }}
47 | {{- end }}
48 |
49 | {{- end }}
50 |
--------------------------------------------------------------------------------
/doc/content/en/type/bool.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Bool
3 | weight: 10
4 | ---
5 |
6 | {{< toc >}}
7 |
8 |
9 |
10 | ## Bool
11 | Convert an interface to a bool type, with default value.
12 |
13 | ```go
14 | cvt.Bool(0) // false
15 | cvt.Bool(nil) // false
16 | cvt.Bool("0") // false
17 | cvt.Bool("false") // false
18 | cvt.Bool([]int{}) // false
19 |
20 | cvt.Bool(true) // true
21 | cvt.Bool("true") // true
22 | cvt.Bool([]int{1, 2}) // true
23 | cvt.Bool([]byte("true")) // true
24 | ```
25 |
26 | ## BoolE
27 | Convert an interface to a bool type.
28 |
29 | ```go
30 | cvt.BoolE(0) // false,nil
31 | cvt.BoolE(nil) // false,nil
32 | cvt.BoolE("0") // false,nil
33 | cvt.BoolE("false") // false,nil
34 | cvt.BoolE([]int{}) // false,nil
35 |
36 | cvt.BoolE(true) // true,nil
37 | cvt.BoolE("true") // true,nil
38 | cvt.BoolE([]int{1, 2}) // true,nil
39 | cvt.BoolE([]byte("true")) // true,nil
40 | ```
41 |
42 | ## BoolP
43 | Convert and store in a new bool value, and returns a pointer to it.
44 |
45 | ```go
46 | cvt.BoolP("true") // (*bool)(0x14000126180)(true)
47 | ```
48 |
49 |
50 | ## Conversion rule
51 | ### nil
52 | Return `false`
53 |
54 | ### Bool
55 | Return original value
56 |
57 | ### Number
58 | > Integer, Float, and their derived type, such as `time.Duration` of `int64`
59 |
60 | If `val != 0`, then return `true`; otherwise return `false`.
61 |
62 | ### String
63 | > `string`, `[]byte`, and their derived type
64 |
65 | ### json.Number
66 | If value can convert to `float64`, then compare `val != 0`; if not a number string, report an error.
67 |
68 | ### Array/Slice/Map
69 | If the number of elements (len) greater than `0`, the return `true`; Return to `false` otherwise.
70 |
71 | ### Others
72 | Other types, report an error.
73 |
74 |
75 | ## More Examples
76 | More case see unit: `bool_test.go`
77 |
78 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/head/others.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
17 |
18 |
23 |
28 |
29 |
34 |
39 |
40 |
45 |
50 |
51 |
56 |
61 |
62 | {{- with .OutputFormats.Get "html" }}
63 | {{ printf ` ` .Permalink .Rel .MediaType.Type | safeHTML }}
64 | {{- end }}
65 |
66 | {{- if (default false $.Site.Params.GeekdocOverwriteHTMLBase) }}
67 |
68 | {{- end }}
69 |
70 | {{ printf "" "Made with Geekdoc theme https://github.com/thegeeklab/hugo-geekdoc" | safeHTML }}
71 |
--------------------------------------------------------------------------------
/README_ZH.md:
--------------------------------------------------------------------------------
1 | # cvt
2 |
3 | [](https://pkg.go.dev/github.com/shockerli/cvt)
4 | [](https://goreportcard.com/report/github.com/shockerli/cvt)
5 | [](https://travis-ci.com/shockerli/cvt)
6 | [](https://codecov.io/gh/shockerli/cvt)
7 | 
8 | [](https://github.com/avelino/awesome-go)
9 |
10 | > 一个简单、安全、高效的转换任意数据类型的 Go 语言工具包,支持自定义类型、提取结构体字段和值
11 |
12 |
13 | ## 帮助文档
14 | https://cvt.shockerli.net
15 |
16 |
17 | ## 安装
18 | > Go >= 1.13
19 |
20 | ```go
21 | go get -u github.com/shockerli/cvt
22 | ```
23 |
24 | ## 使用
25 |
26 | 中文 | [English](README.md)
27 |
28 | ### 支持 `error`
29 |
30 | > 以 `E` 结尾的方法 `__E()`: 当转换失败时会返回错误
31 |
32 | ```go
33 | cvt.IntE("12") // 12, nil
34 | cvt.Float64E("12.34") // 12.34, nil
35 | cvt.StringE(12.34) // "12.34", nil
36 | cvt.BoolE("false") // false, nil
37 | ```
38 |
39 | ### 自定义类型、指针类型
40 |
41 | > 自动解引用,并找到基本类型,完全支持自定义类型的转换
42 |
43 | ```go
44 | type Name string
45 |
46 | var name Name = "jioby"
47 |
48 | cvt.StringE(name) // jioby, nil
49 | cvt.StringE(&name) // jioby, nil
50 | ```
51 |
52 | ### 忽略 `error`
53 |
54 | > 名称不以 `E` 结尾的方法,如果转换失败,不会返回错误,会返回零值
55 |
56 | ```go
57 | cvt.Int("12") // 12(success)
58 | cvt.Int(struct{}{}) // 0(failed)
59 | ```
60 |
61 | ### 默认值
62 |
63 | > 如果转换失败,返回默认值
64 |
65 | ```go
66 | cvt.Int(struct{}{}, 12) // 12
67 | cvt.Float("hello", 12.34) // 12.34
68 | ```
69 |
70 | ### 更多示例
71 |
72 | > 上千个单元测试用例,覆盖率近100%,所有示例可通过单元测试了解:`*_test.go`
73 |
74 |
75 | ## 开源协议
76 |
77 | 本项目基于 [MIT](LICENSE) 协议开放源代码。
78 |
79 | ## 感谢
80 | - [JetBrains Open Source Support](https://jb.gg/OpenSourceSupport)
81 |
82 | 
83 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/shortcodes/img.html:
--------------------------------------------------------------------------------
1 | {{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
2 | {{- $customAlt := .Get "alt" }}
3 | {{- $customSize := .Get "size" | lower }}
4 | {{- $lazyLoad := default (default true $.Site.Params.GeekdocImageLazyLoading) (.Get "lazy") }}
5 |
6 | {{- with $source }}
7 | {{- $caption := default .Title $customAlt }}
8 |
9 | {{- $origin := .Permalink }}
10 | {{- $profile := (.Fill "180x180 Center").Permalink }}
11 | {{- $tiny := (.Resize "320x").Permalink }}
12 | {{- $small := (.Resize "600x").Permalink }}
13 | {{- $medium := (.Resize "1200x").Permalink }}
14 | {{- $large := (.Resize "1800x").Permalink }}
15 |
16 | {{- $size := dict "origin" $origin "profile" $profile "tiny" $tiny "small" $small "medium" $medium "large" $large }}
17 |
18 |
19 |
20 |
24 |
25 |
26 |
33 |
42 |
43 |
44 | {{- if not (eq $customSize "profile") }}
45 | {{- with $caption }}
46 |
47 | {{ . }}
48 | {{- with $source.Params.credits }}
49 | {{ printf " (%s)" . | $.Page.RenderString }}
50 | {{- end }}
51 |
52 | {{- end }}
53 | {{- end }}
54 |
55 |
56 | {{- end }}
57 |
--------------------------------------------------------------------------------
/string.go:
--------------------------------------------------------------------------------
1 | package cvt
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 | "strconv"
7 | )
8 |
9 | // String convert an interface to a string type, with default value
10 | func String(v interface{}, def ...string) string {
11 | if v, err := StringE(v); err == nil {
12 | return v
13 | }
14 |
15 | if len(def) > 0 {
16 | return def[0]
17 | }
18 |
19 | return ""
20 | }
21 |
22 | // StringP convert and store in a new string value, and returns a pointer to it
23 | func StringP(v interface{}, def ...string) *string {
24 | s := String(v, def...)
25 | return &s
26 | }
27 |
28 | // StringE convert an interface to a string type
29 | func StringE(val interface{}) (string, error) {
30 | // interface implements
31 | switch vv := val.(type) {
32 | case fmt.Stringer:
33 | return vv.String(), nil
34 | case error:
35 | return vv.Error(), nil
36 | case json.Marshaler:
37 | vvv, e := vv.MarshalJSON()
38 | if e == nil {
39 | return string(vvv), nil
40 | }
41 | }
42 |
43 | // direct type
44 | switch vv := val.(type) {
45 | case nil:
46 | return "", nil
47 | case bool:
48 | return strconv.FormatBool(vv), nil
49 | case string:
50 | return vv, nil
51 | case []byte:
52 | return string(vv), nil
53 | case []rune:
54 | return string(vv), nil
55 | case uint, uint8, uint16, uint32, uint64, uintptr:
56 | return strconv.FormatUint(Uint64(vv), 10), nil
57 | case int, int8, int16, int32, int64:
58 | return strconv.FormatInt(Int64(vv), 10), nil
59 | case float64:
60 | return strconv.FormatFloat(vv, 'f', -1, 64), nil
61 | case float32:
62 | return strconv.FormatFloat(float64(vv), 'f', -1, 32), nil
63 | }
64 |
65 | // indirect type
66 | v, rv := Indirect(val)
67 | switch vv := v.(type) {
68 | case nil:
69 | return "", nil
70 | case bool:
71 | return strconv.FormatBool(vv), nil
72 | case string:
73 | return vv, nil
74 | case []byte:
75 | return string(vv), nil
76 | case []rune:
77 | return string(vv), nil
78 | case uint, uint8, uint16, uint32, uint64, uintptr:
79 | return strconv.FormatUint(rv.Uint(), 10), nil
80 | case int, int8, int16, int32, int64:
81 | return strconv.FormatInt(rv.Int(), 10), nil
82 | case float64:
83 | return strconv.FormatFloat(vv, 'f', -1, 64), nil
84 | case float32:
85 | return strconv.FormatFloat(float64(vv), 'f', -1, 32), nil
86 | }
87 |
88 | return "", newErr(val, "string")
89 | }
90 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cvt
2 |
3 | [](https://pkg.go.dev/github.com/shockerli/cvt)
4 | [](https://goreportcard.com/report/github.com/shockerli/cvt)
5 | [](https://travis-ci.com/shockerli/cvt)
6 | [](https://codecov.io/gh/shockerli/cvt)
7 | 
8 | [](https://github.com/avelino/awesome-go)
9 |
10 | > Simple, safe conversion of any type, including indirect/custom types.
11 |
12 |
13 | ## Documents
14 | https://cvt.shockerli.net
15 |
16 |
17 | ## Install
18 | > Go >= 1.13
19 |
20 | ```go
21 | go get -u github.com/shockerli/cvt
22 | ```
23 |
24 | ## Usage
25 |
26 | English | [中文](README_ZH.md)
27 |
28 | ### with `error`
29 |
30 | > Method `__E()`: expect handle error, while unable to convert
31 |
32 | ```go
33 | cvt.IntE("12") // 12, nil
34 | cvt.Float64E("12.34") // 12.34, nil
35 | cvt.StringE(12.34) // "12.34", nil
36 | cvt.BoolE("false") // false, nil
37 | ```
38 |
39 | ### custom type and pointers
40 |
41 | > dereferencing pointer and reach the original type
42 |
43 | ```go
44 | type Name string
45 |
46 | var name Name = "jioby"
47 |
48 | cvt.StringE(name) // jioby, nil
49 | cvt.StringE(&name) // jioby, nil
50 | ```
51 |
52 | ### ignore `error`
53 |
54 | > Method `__()`: ignore error, while convert failed, will return the zero value of type
55 |
56 | ```go
57 | cvt.Int("12") // 12(success)
58 | cvt.Int(struct{}{}) // 0(failed)
59 | ```
60 |
61 | ### with default
62 |
63 | > return the default value, while convert failed
64 |
65 | ```go
66 | cvt.Int(struct{}{}, 12) // 12
67 | cvt.Float("hello", 12.34) // 12.34
68 | ```
69 |
70 | ### more
71 |
72 | > 1000+ unit test cases, for more examples, see `*_test.go`
73 |
74 |
75 | ## License
76 |
77 | This project is under the terms of the [MIT](LICENSE) license.
78 |
79 | ## Thanks
80 | - [JetBrains Open Source Support](https://jb.gg/OpenSourceSupport)
81 |
82 | 
83 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Go 类型转换工具包
3 | geekdocNav: false
4 | geekdocAlign: center
5 | geekdocAnchor: false
6 | ---
7 |
8 |
9 |
10 |
11 | [](https://pkg.go.dev/github.com/shockerli/cvt)
12 | [](https://goreportcard.com/report/github.com/shockerli/cvt)
13 | [](https://travis-ci.com/shockerli/cvt)
14 | [](https://codecov.io/gh/shockerli/cvt)
15 | 
16 | [](https://github.com/avelino/awesome-go)
17 |
18 |
19 |
20 | 一个简单、安全、高效的转换任意数据类型的 Go 语言工具包,支持自定义类型、提取结构体字段和值
21 |
22 | {{< button relref="usage/getting-started" >}}快速上手{{< /button >}}
23 |
24 | ## 特性
25 |
26 | {{< columns >}}
27 |
28 | ### 安全
29 |
30 | 支持传入任意类型数据,不会造成恐慌,程序安全运行
31 |
32 | <--->
33 |
34 | ### 轻量
35 |
36 | 代码少、零依赖,对应用程序几乎无臃肿负担
37 |
38 | <--->
39 |
40 | ### 易用
41 |
42 | 语义清晰、命名统一、文档详细、直接上手
43 |
44 | {{< /columns >}}
45 |
46 |
47 | ## 示例
48 |
49 | {{< tabs "index-example" >}}
50 | {{< tab "WITH ERROR" >}}
51 | ```go
52 | cvt.IntE("12") // 12, nil
53 | cvt.Float64E("12.34") // 12.34, nil
54 | cvt.StringE(12.34) // "12.34", nil
55 | cvt.BoolE("false") // false, nil
56 | ```
57 | {{< /tab >}}
58 |
59 | {{< tab "IGNORE ERROR" >}}
60 | ```go
61 | cvt.Int("12") // 12(success)
62 | cvt.Int(struct{}{}) // 0(failed)
63 | ```
64 | {{< /tab >}}
65 |
66 | {{< tab "WITH DEFAULT" >}}
67 | ```go
68 | cvt.Int(struct{}{}, 12) // 12
69 | cvt.Float("hello", 12.34) // 12.34
70 | ```
71 | {{< /tab >}}
72 |
73 | {{< tab "CUSTOM TYPE" >}}
74 | ```go
75 | type Name string
76 |
77 | var name Name = "jioby"
78 |
79 | cvt.StringE(name) // jioby, nil
80 | ```
81 | {{< /tab >}}
82 |
83 | {{< tab "INDIRECT" >}}
84 | ```go
85 | var name = "jioby"
86 |
87 | cvt.StringE(&name) // jioby, nil
88 | ```
89 | {{< /tab >}}
90 |
91 | {{< tab "POINTER" >}}
92 | ```go
93 | cvt.BoolP("true") // (*bool)(0x14000126180)(true)
94 | ```
95 | {{< /tab >}}
96 |
97 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/microformats/opengraph.html:
--------------------------------------------------------------------------------
1 | {{ $isPage := or (and (ne .Type "posts") (in "section page" .Kind )) (and (eq .Type "posts") (eq .Kind "page")) }}
2 |
3 | {{- if ne .Kind "home" }}
4 |
8 | {{- end }}
9 | {{- with .Site.Title }}
10 |
11 | {{- end }}
12 | {{- with partial "utils/featured" . }}
13 |
14 | {{- end }}
15 | {{- with partial "utils/description" . }}
16 |
17 | {{- end }}
18 |
19 |
20 | {{- with .Params.audio }}
21 |
22 | {{- end }}
23 | {{- with .Params.locale }}
24 |
25 | {{- end }}
26 | {{- with .Params.videos }}
27 | {{- range . }}
28 |
29 | {{- end }}
30 | {{- end }}
31 |
32 | {{- /* If it is part of a series, link to related articles */}}
33 | {{- if .Site.Taxonomies.series }}
34 | {{- $permalink := .Permalink -}}
35 | {{- $siteSeries := .Site.Taxonomies.series -}}
36 | {{- with .Params.series }}
37 | {{- range $name := . }}
38 | {{- $series := index $siteSeries ($name | urlize) }}
39 | {{- range $page := first 6 $series.Pages }}
40 | {{- if ne $page.Permalink $permalink }}
41 |
42 | {{- end }}
43 | {{- end }}
44 | {{- end }}
45 | {{- end }}
46 | {{- end }}
47 |
48 | {{ if $isPage -}}
49 | {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
50 |
51 | {{- with .PublishDate }}
52 |
56 | {{- end }}
57 | {{- with .Lastmod }}
58 |
62 | {{- end }}
63 | {{- end }}
64 |
65 | {{- /* Facebook Page Admin ID for Domain Insights */}}
66 | {{- with .Site.Social.facebook_admin }}
67 |
68 | {{- end }}
69 |
--------------------------------------------------------------------------------
/bool.go:
--------------------------------------------------------------------------------
1 | package cvt
2 |
3 | import (
4 | "encoding/json"
5 | "reflect"
6 | "strconv"
7 | "strings"
8 | "time"
9 | )
10 |
11 | // Bool convert an interface to a bool type, with default value
12 | func Bool(v interface{}, def ...bool) bool {
13 | if v, err := BoolE(v); err == nil {
14 | return v
15 | }
16 |
17 | if len(def) > 0 {
18 | return def[0]
19 | }
20 |
21 | return false
22 | }
23 |
24 | // BoolP convert and store in a new bool value, and returns a pointer to it
25 | func BoolP(v interface{}, def ...bool) *bool {
26 | i := Bool(v, def...)
27 | return &i
28 | }
29 |
30 | // BoolE convert an interface to a bool type
31 | func BoolE(val interface{}) (bool, error) {
32 | // direct type(for improve performance)
33 | switch vv := val.(type) {
34 | case nil:
35 | return false, nil
36 | case bool:
37 | return vv, nil
38 | case
39 | float32, float64:
40 | return Float64(vv) != 0, nil
41 | case
42 | time.Duration,
43 | int, int8, int16, int32, int64:
44 | return Int64(vv) != 0, nil
45 | case uint, uint8, uint16, uint32, uint64:
46 | return Uint64(vv) != 0, nil
47 | case []byte:
48 | return str2bool(string(vv))
49 | case string:
50 | return str2bool(vv)
51 | case json.Number:
52 | vvv, err := vv.Float64()
53 | if err != nil {
54 | return false, newErr(val, "bool")
55 | }
56 | return vvv != 0, nil
57 | }
58 |
59 | // indirect type
60 | v, rv := Indirect(val)
61 |
62 | switch vv := v.(type) {
63 | case nil:
64 | return false, nil
65 | case bool:
66 | return vv, nil
67 | case int, int8, int16, int32, int64:
68 | return rv.Int() != 0, nil
69 | case uint, uint8, uint16, uint32, uint64:
70 | return rv.Uint() != 0, nil
71 | case float32, float64:
72 | return rv.Float() != 0, nil
73 | case []byte:
74 | return str2bool(string(vv))
75 | case string:
76 | return str2bool(vv)
77 | }
78 |
79 | switch rv.Kind() {
80 | // by elem length
81 | case reflect.Array, reflect.Slice, reflect.Map:
82 | return rv.Len() > 0, nil
83 | }
84 |
85 | return false, newErr(val, "bool")
86 | }
87 |
88 | // returns the boolean value represented by the string
89 | func str2bool(str string) (bool, error) {
90 | if val, err := strconv.ParseBool(str); err == nil {
91 | return val, nil
92 | } else if val, err := strconv.ParseFloat(str, 64); err == nil {
93 | return val != 0, nil
94 | }
95 |
96 | switch strings.ToLower(strings.TrimSpace(str)) {
97 | case "on", "yes", "y":
98 | return true, nil
99 | case "off", "no", "n":
100 | return false, nil
101 | default:
102 | return false, newErr(str, "bool")
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/doc/content/en/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'Go type conversion'
3 | geekdocNav: false
4 | geekdocAlign: center
5 | geekdocAnchor: false
6 | ---
7 |
8 |
9 |
10 |
11 | [](https://pkg.go.dev/github.com/shockerli/cvt)
12 | [](https://goreportcard.com/report/github.com/shockerli/cvt)
13 | [](https://travis-ci.com/shockerli/cvt)
14 | [](https://codecov.io/gh/shockerli/cvt)
15 | 
16 | [](https://github.com/avelino/awesome-go)
17 |
18 |
19 |
20 | Simple, safe conversion of any type, including indirect/custom types.
21 |
22 | {{< button size="large" relref="usage/getting-started" >}}Getting Started{{< /button >}}
23 |
24 | ## Feature overview
25 |
26 | {{< columns >}}
27 |
28 | ### Safety
29 |
30 | Support to any data type, no panic, safe with application.
31 |
32 | <--->
33 |
34 | ### Lightweight
35 |
36 | Less code, zero depend, the application almost no heavy burden.
37 |
38 | <--->
39 |
40 | ### Easily
41 |
42 | Semantic clarity, naming, documentation, detailed, directly get started.
43 |
44 | {{< /columns >}}
45 |
46 | ## Examples
47 |
48 | {{< tabs "index-example" >}}
49 | {{< tab "WITH ERROR" >}}
50 | ```go
51 | cvt.IntE("12") // 12, nil
52 | cvt.Float64E("12.34") // 12.34, nil
53 | cvt.StringE(12.34) // "12.34", nil
54 | cvt.BoolE("false") // false, nil
55 | ```
56 | {{< /tab >}}
57 |
58 | {{< tab "IGNORE ERROR" >}}
59 | ```go
60 | cvt.Int("12") // 12(success)
61 | cvt.Int(struct{}{}) // 0(failed)
62 | ```
63 | {{< /tab >}}
64 |
65 | {{< tab "WITH DEFAULT" >}}
66 | ```go
67 | cvt.Int(struct{}{}, 12) // 12
68 | cvt.Float("hello", 12.34) // 12.34
69 | ```
70 | {{< /tab >}}
71 |
72 | {{< tab "CUSTOM TYPE" >}}
73 | ```go
74 | type Name string
75 |
76 | var name Name = "jioby"
77 |
78 | cvt.StringE(name) // jioby, nil
79 | ```
80 | {{< /tab >}}
81 |
82 | {{< tab "INDIRECT" >}}
83 | ```go
84 | var name = "jioby"
85 |
86 | cvt.StringE(&name) // jioby, nil
87 | ```
88 | {{< /tab >}}
89 |
90 | {{< tab "POINTER" >}}
91 | ```go
92 | cvt.BoolP("true") // (*bool)(0x14000126180)(true)
93 | ```
94 | {{< /tab >}}
95 |
96 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/microformats/schema.html:
--------------------------------------------------------------------------------
1 | {{ $isPage := or (and (ne .Type "posts") (in "section page" .Kind )) (and (eq .Type "posts") (eq .Kind "page")) }}
2 | {{- if eq .Kind "home" }}
3 |
21 | {{- else if $isPage }}
22 |
70 | {{- end }}
71 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/menu-nextprev.html:
--------------------------------------------------------------------------------
1 | {{ $current := . }}
2 | {{ $site := .Site }}
3 | {{ $current.Scratch.Set "prev" false }}
4 | {{ $current.Scratch.Set "getNext" false }}
5 |
6 | {{ $current.Scratch.Set "nextPage" false }}
7 | {{ $current.Scratch.Set "prevPage" false }}
8 |
9 | {{ template "menu_nextprev" dict "sect" $.Site.Data.menu.main.main "current" $current "site" $site }}
10 |
11 | {{ define "menu_nextprev" }}
12 | {{ $current := .current }}
13 | {{ $site := .site }}
14 |
15 | {{ range sort (default (seq 0) .sect) "weight" }}
16 | {{ $current.Scratch.Set "current" $current }}
17 | {{ $current.Scratch.Set "site" $site }}
18 |
19 | {{ $ref := default false .ref }}
20 | {{ if $ref }}
21 | {{ $site := $current.Scratch.Get "site" }}
22 | {{ $this := $site.GetPage .ref }}
23 | {{ $current := $current.Scratch.Get "current" }}
24 |
25 | {{ if reflect.IsMap .name }}
26 | {{ $current.Scratch.Set "refName" (index .name $site.Language.Lang) }}
27 | {{ else }}
28 | {{ $current.Scratch.Set "refName" .name }}
29 | {{ end }}
30 | {{ $name := $current.Scratch.Get "refName" }}
31 |
32 | {{ if $current.Scratch.Get "getNext" }}
33 | {{ $current.Scratch.Set "nextPage" (dict "name" $name "this" $this) }}
34 | {{ $current.Scratch.Set "getNext" false }}
35 | {{ end }}
36 |
37 | {{ if eq $current $this }}
38 | {{ $current.Scratch.Set "prevPage" ($current.Scratch.Get "prev") }}
39 | {{ $current.Scratch.Set "getNext" true }}
40 | {{ end }}
41 |
42 | {{ $current.Scratch.Set "prev" (dict "name" $name "this" $this) }}
43 | {{ end }}
44 |
45 | {{ $sub := default false .sub }}
46 | {{ if $sub }}
47 | {{ template "menu_nextprev" dict "sect" $sub "current" ($current.Scratch.Get "current") "site" ($current.Scratch.Get "site") }}
48 | {{ end }}
49 | {{ end }}
50 | {{ end }}
51 |
52 | {{ $showPrevNext := (and (default true .Site.Params.GeekdocNextPrev) .Site.Params.GeekdocMenuBundle) }}
53 | {{ if $showPrevNext }}
54 |
55 | {{ with ($current.Scratch.Get "prevPage") }}
56 |
61 | gdoc_arrow_left_alt
62 | {{ .name }}
63 |
64 | {{ end }}
65 |
66 |
67 | {{ with ($current.Scratch.Get "nextPage") }}
68 |
73 | {{ .name }}
74 | gdoc_arrow_right_alt
75 |
76 | {{ end }}
77 |
78 | {{ end }}
79 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/page-header.html:
--------------------------------------------------------------------------------
1 | {{ $geekdocRepo := default (default false .Site.Params.GeekdocRepo) .Page.Params.GeekdocRepo }}
2 | {{ $geekdocEditPath := default (default false .Site.Params.GeekdocEditPath) .Page.Params.GeekdocEditPath }}
3 | {{ if .File }}
4 | {{ $.Scratch.Set "geekdocFilePath" (default (path.Join (default "content" .Site.Params.contentDir) .File.Path) .Page.Params.GeekdocFilePath) }}
5 | {{ else }}
6 | {{ $.Scratch.Set "geekdocFilePath" false }}
7 | {{ end }}
8 |
9 | {{ define "breadcrumb" }}
10 | {{ $parent := .page.Parent }}
11 | {{ if $parent }}
12 | {{ $name := (partial "utils/title" $parent) }}
13 | {{ $position := (sub .position 1) }}
14 | {{ $value := (printf "%s / %s" $parent.RelPermalink $parent.RelPermalink $name $position .value) }}
15 | {{ template "breadcrumb" dict "page" $parent "value" $value "position" $position }}
16 | {{ else }}
17 | {{ .value | safeHTML }}
18 | {{ end }}
19 | {{ end }}
20 |
21 | {{ $showBreadcrumb := (and (default true .Page.Params.GeekdocBreadcrumb) (default true .Site.Params.GeekdocBreadcrumb)) }}
22 | {{ $showEdit := (and ($.Scratch.Get "geekdocFilePath") $geekdocRepo $geekdocEditPath) }}
23 |
34 | {{ if $showBreadcrumb }}
35 |
36 |
37 |
38 | {{ $position := sub (len (split .RelPermalink "/")) 1 }}
39 | {{ $name := (partial "utils/title" .) }}
40 | {{ $value := (printf "%s " $name $position ) }}
41 | {{ template "breadcrumb" dict "page" . "value" $value "position" $position }}
42 |
43 |
44 | {{ end }}
45 | {{ if $showEdit }}
46 |
56 | {{ end }}
57 |
58 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/site-header.html:
--------------------------------------------------------------------------------
1 |
79 |
--------------------------------------------------------------------------------
/map.go:
--------------------------------------------------------------------------------
1 | package cvt
2 |
3 | import (
4 | "encoding/json"
5 | "reflect"
6 | )
7 |
8 | // IntMapE convert an interface to `map[int]interface{}`
9 | // * Support JSON string of map
10 | // * Support any `map` type
11 | func IntMapE(val interface{}) (m map[int]interface{}, err error) {
12 | m = make(map[int]interface{})
13 | if val == nil {
14 | return nil, errUnsupportedTypeNil
15 | }
16 |
17 | // direct type(for improve performance)
18 | switch v := val.(type) {
19 | case map[int]interface{}:
20 | return v, nil
21 | }
22 |
23 | // indirect type
24 | _, rv := Indirect(val)
25 | switch rv.Kind() {
26 | case reflect.Map:
27 | var idx int
28 | for _, key := range rv.MapKeys() {
29 | idx, err = IntE(key.Interface())
30 | if err != nil {
31 | return
32 | }
33 | m[idx] = rv.MapIndex(key).Interface()
34 | }
35 | case reflect.Slice:
36 | // []byte
37 | // Example: []byte(`{1:"bob",2:18}`)
38 | if rv.Type().Elem().Kind() == reflect.Uint8 {
39 | err = json.Unmarshal(rv.Bytes(), &m)
40 | }
41 | case reflect.String:
42 | // JSON string of map
43 | // Example: `{1:"bob",2:18}`
44 | err = json.Unmarshal([]byte(rv.String()), &m)
45 | }
46 |
47 | return
48 | }
49 |
50 | // StringMapE convert an interface to `map[string]interface{}`
51 | // * Support JSON string of map
52 | // * Support any `map` type
53 | // * Support any `struct` type
54 | func StringMapE(val interface{}) (m map[string]interface{}, err error) {
55 | m = make(map[string]interface{})
56 | if val == nil {
57 | return nil, errUnsupportedTypeNil
58 | }
59 |
60 | // direct type(for improve performance)
61 | switch v := val.(type) {
62 | case map[string]interface{}:
63 | return v, nil
64 | case []byte:
65 | err = json.Unmarshal(v, &m)
66 | return
67 | case string:
68 | err = json.Unmarshal([]byte(v), &m)
69 | return
70 | }
71 |
72 | // indirect type
73 | _, rv := Indirect(val)
74 | switch rv.Kind() {
75 | case reflect.Map:
76 | for _, key := range rv.MapKeys() {
77 | m[String(key.Interface())] = rv.MapIndex(key).Interface()
78 | }
79 | case reflect.Struct:
80 | m = struct2map(rv)
81 | case reflect.Slice:
82 | // []byte, JSON
83 | // Example: []byte(`{"name":"bob","age":18}`)
84 | if rv.Type().Elem().Kind() == reflect.Uint8 {
85 | err = json.Unmarshal(rv.Bytes(), &m)
86 | }
87 | case reflect.String:
88 | // JSON string of map
89 | // Example: `{"name":"bob","age":18}`
90 | err = json.Unmarshal([]byte(rv.String()), &m)
91 | }
92 |
93 | return
94 | }
95 |
96 | func struct2map(rv reflect.Value) map[string]interface{} {
97 | var m = make(map[string]interface{})
98 | if !rv.IsValid() {
99 | return m
100 | }
101 |
102 | for j := 0; j < rv.NumField(); j++ {
103 | f := rv.Type().Field(j)
104 | t := ptrType(f.Type)
105 | vv := ptrValue(rv.Field(j))
106 | if f.Anonymous && t.Kind() == reflect.Struct {
107 | for k, v := range struct2map(vv) {
108 | // anonymous subfield has a low priority
109 | if _, ok := m[k]; !ok {
110 | m[k] = v
111 | }
112 | }
113 | } else if vv.IsValid() && vv.CanInterface() {
114 | m[f.Name] = vv.Interface()
115 | }
116 | }
117 | return m
118 | }
119 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/README.md:
--------------------------------------------------------------------------------
1 | # Geekdoc
2 |
3 | [](https://drone.thegeeklab.de/thegeeklab/hugo-geekdoc)
4 | [](https://gohugo.io)
5 | [](https://github.com/thegeeklab/hugo-geekdoc/releases/latest)
6 | [](https://github.com/thegeeklab/hugo-geekdoc/graphs/contributors)
7 | [](https://github.com/thegeeklab/hugo-geekdoc/blob/main/LICENSE)
8 |
9 | Geekdoc is a simple Hugo theme for documentations. It is intentionally designed as a fast and lean theme and may not fit the requirements of complex projects. If a more feature-complete theme is required there are a lot of good alternatives out there. You can find a demo and the full documentation at [https://geekdocs.de](https://geekdocs.de).
10 |
11 | 
12 |
13 | ## Build and release process
14 |
15 | This theme is subject to a CI driven build and release process common for software development. During the release build, all necessary assets are automatically built by [webpack](https://webpack.js.org/) and bundled in a release tarball. You can download the latest release from the GitHub [release page](https://github.com/thegeeklab/hugo-geekdoc/releases).
16 |
17 | Due to the fact that `webpack` and `npm scripts` are used as pre-processors, the theme cannot be used from the main branch by default. If you want to use the theme from a cloned branch instead of a release tarball you'll need to install `webpack` locally and run the build script once to create all required assets.
18 |
19 | ```Shell
20 | # install required packages from package.json
21 | npm install
22 |
23 | # run the build script to build required assets
24 | npm run build
25 |
26 | # build release tarball
27 | npm run pack
28 | ```
29 |
30 | See the [Getting Started Guide](https://geekdocs.de/usage/getting-started/) for details about the different setup options.
31 |
32 | ## Contributors
33 |
34 | Special thanks to all [contributors](https://github.com/thegeeklab/hugo-geekdoc/graphs/contributors). If you would like to contribute, please see the [instructions](https://github.com/thegeeklab/hugo-geekdoc/blob/main/CONTRIBUTING.md).
35 |
36 | Geekdoc is inspired and partially based on the [hugo-book](https://github.com/alex-shpak/hugo-book) theme, thanks [Alex Shpak](https://github.com/alex-shpak/) for your work.
37 |
38 | ## License
39 |
40 | This project is licensed under the MIT License - see the [LICENSE](https://github.com/thegeeklab/hugo-geekdoc/blob/main/LICENSE) file for details.
41 |
42 | The used SVG icons and generated icon fonts are licensed under the license of the respective icon pack:
43 |
44 | - Font Awesome: [CC BY 4.0 License](https://github.com/FortAwesome/Font-Awesome#license)
45 | - IcoMoon Free Pack: [GPL/CC BY 4.0](https://icomoon.io/#icons-icomoon)
46 | - Material Icons: [Apache License 2.0](https://github.com/google/material-design-icons/blob/main/LICENSE)
47 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/menu-bundle.html:
--------------------------------------------------------------------------------
1 | {{ $current := .current }}
2 | {{ template "menu-file" dict "sect" .source "current" $current "site" $current.Site }}
3 |
4 |
5 |
6 | {{ define "menu-file" }}
7 | {{ $current := .current }}
8 | {{ $site := .site }}
9 |
10 |
11 |
87 | {{ end }}
88 |
--------------------------------------------------------------------------------
/doc/content/zh-cn/type/slice.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Slice
3 | weight: 60
4 | ---
5 |
6 |
7 |
8 | {{< toc >}}
9 |
10 | ## ColumnsE
11 | 返回切片或字典中的某个字段切片,字段可是字典的键值或结构体的字段。
12 |
13 | `FieldE` 函数的切片版本,返回 `[]interface{}`。
14 |
15 | 类似于 `PHP` 中的 `array_column`。
16 |
17 | ```go
18 | // []interface{}{"D1", "D2", nil}
19 | cvt.ColumnsE([]map[string]interface{}{
20 | {"1": 111, "DDD": "D1"},
21 | {"2": 222, "DDD": "D2"},
22 | {"DDD": nil},
23 | }, "DDD")
24 |
25 | // test type
26 | type TestStructD struct {
27 | D1 int
28 | }
29 | type TestStructE struct {
30 | D1 int
31 | DD *TestStructD
32 | }
33 |
34 | // []interface{}{11, 22}
35 | cvt.ColumnsE(map[int]TestStructD{1: {11}, 2: {22}}, "D1")
36 |
37 | // []interface{}{1, 2}
38 | cvt.ColumnsE([]TestStructE{{D1: 1}, {D1: 2}}, "D1")
39 | ```
40 |
41 | ## KeysE
42 | 取 `map` 的键名,或结构体的字段名,返回 `[]interface{}`。
43 |
44 | ```go
45 | cvt.KeysE()
46 | // key of map
47 | cvt.KeysE(map[float64]float64{0.1: -0.1, -1.2: 1.2}) // []interface{}{-1.2, 0.1}
48 | cvt.KeysE(map[string]interface{}{"A": 1, "2": 2}) // []interface{}{"2", "A"}
49 | cvt.KeysE(map[int]map[string]interface{}{1: {"1": 111, "DDD": 12.3}, -2: {"2": 222, "DDD": "321"}, 3: {"DDD": nil}}) // []interface{}{-2, 1, 3}
50 |
51 | // field name of struct
52 | cvt.KeysE(struct{
53 | A string
54 | B int
55 | C float
56 | }{}) // []interface{}{"A", "B", "C"}
57 |
58 | type TestStructB {
59 | B int
60 | }
61 | cvt.KeysE(struct{
62 | A string
63 | TestStructB
64 | C float
65 | }{}) // []interface{}{"A", "B", "C"}
66 | ```
67 |
68 |
69 | ## Slice
70 | 参考 `SliceE` 方法。
71 |
72 | ## SliceE
73 | 转换成 `[]interface{}`
74 |
75 | ```go
76 | cvt.SliceE("hello") // []interface{}{'h', 'e', 'l', 'l', 'o'}
77 | cvt.SliceE([]byte("hey")) // []interface{}{byte('h'), byte('e'), byte('y')}
78 | cvt.SliceE([]int{1, 2, 3}) // []interface{}{1, 2, 3}
79 | cvt.SliceE([]string{"a", "b", "c"}) // []interface{}{"a", "b", "c"}
80 | cvt.SliceE(map[int]string{1: "111", 2: "222"}) // []interface{}{"111", "222"}
81 |
82 | // struct values
83 | type TestStruct struct {
84 | A int
85 | B string
86 | }
87 | cvt.SliceE(TestStruct{18,"jhon"}) // []interface{}{18, "jhon"}
88 | ```
89 |
90 |
91 | ## SliceInt
92 | 参考 `SliceIntE` 方法。
93 |
94 | ## SliceIntE
95 | 转换成 `[]int`
96 |
97 | ```go
98 | cvt.SliceIntE([]string{"1", "2", "3"}) // []int{1, 2, 3}
99 | cvt.SliceIntE(map[int]string{2: "222", 1: "111"}) // []int{111, 222}
100 | ```
101 |
102 | ## SliceInt64
103 | 参考 `SliceInt64E` 方法。
104 |
105 | ## SliceInt64E
106 | 转换成 `[]int64`
107 |
108 | ```go
109 | cvt.SliceInt64E([]string{"1", "2", "3"}) // []int64{1, 2, 3}
110 | cvt.SliceInt64E(map[int]string{2: "222", 1: "111"}) // []int64{111, 222}
111 | ```
112 |
113 |
114 | ## SliceFloat64
115 | 参考 `SliceFloat64E` 方法。
116 |
117 | ## SliceFloat64E
118 | 转换成 `[]float64`
119 |
120 | ```go
121 | cvt.SliceFloat64E([]string{"1", "2", "3"}) // []float64{1, 2, 3}
122 | cvt.SliceFloat64E(map[int]string{2: "222", 1: "111"}) // []float64{111, 222}
123 | ```
124 |
125 | ## SliceString
126 | 参考 `SliceStringE` 方法。
127 |
128 | ## SliceStringE
129 | 转换成 `[]string`
130 |
131 | ```go
132 | cvt.SliceStringE([]float64{1.1, 2.2, 3.0}) // []string{"1.1", "2.2", "3"}
133 | cvt.SliceStringE(map[int]string{2: "222", 1: "11.1"}) // []string{"11.1", "222"}
134 | ```
135 |
136 | > 更多示例请看单元测试:`slice_test.go`
137 |
138 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/favicon/favicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
24 |
42 |
44 |
45 |
47 | image/svg+xml
48 |
50 |
51 |
52 |
53 |
54 |
59 |
62 |
68 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/float.go:
--------------------------------------------------------------------------------
1 | package cvt
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 | "math"
7 | "strconv"
8 | "time"
9 | )
10 |
11 | // Float64 convert an interface to a float64 type, with default value
12 | func Float64(v interface{}, def ...float64) float64 {
13 | if v, err := Float64E(v); err == nil {
14 | return v
15 | }
16 |
17 | if len(def) > 0 {
18 | return def[0]
19 | }
20 |
21 | return 0
22 | }
23 |
24 | // Float64P convert and store in a new float64 value, and returns a pointer to it
25 | func Float64P(v interface{}, def ...float64) *float64 {
26 | i := Float64(v, def...)
27 | return &i
28 | }
29 |
30 | // Float64E convert an interface to a float64 type
31 | func Float64E(val interface{}) (float64, error) {
32 | v, e := convFloat64E(val)
33 | if e := catch("float64", val, e); e != nil {
34 | return 0, e
35 | }
36 | return v, nil
37 | }
38 |
39 | func convFloat64E(val interface{}) (float64, error) {
40 | // direct type(for improve performance)
41 | switch vv := val.(type) {
42 | case nil:
43 | return 0, nil
44 | case bool:
45 | if vv {
46 | return 1, nil
47 | }
48 | return 0, nil
49 | case string:
50 | vvv, err := strconv.ParseFloat(vv, 64)
51 | if err == nil {
52 | return vvv, nil
53 | }
54 | return 0, errConvFail
55 | case []byte:
56 | vvv, err := strconv.ParseFloat(string(vv), 64)
57 | if err == nil {
58 | return vvv, nil
59 | }
60 | return 0, errConvFail
61 | case uint, uint8, uint16, uint32, uint64, uintptr:
62 | return float64(Uint64(vv)), nil
63 | case int, int8, int16, int32, int64:
64 | return float64(Int(vv)), nil
65 | case float32:
66 | // use fmt to fix float32 -> float64 precision loss
67 | // eg: cvt.Float64E(float32(8.31))
68 | return strconv.ParseFloat(fmt.Sprintf("%f", vv), 64)
69 | case float64:
70 | return vv, nil
71 | case json.Number:
72 | return vv.Float64()
73 | case time.Duration:
74 | return float64(vv), nil
75 | }
76 |
77 | // indirect type
78 | v, rv := Indirect(val)
79 |
80 | switch vv := v.(type) {
81 | case nil:
82 | return 0, nil
83 | case bool:
84 | if vv {
85 | return 1, nil
86 | }
87 | return 0, nil
88 | case string:
89 | return strconv.ParseFloat(vv, 64)
90 | case []byte:
91 | return strconv.ParseFloat(string(vv), 64)
92 | case uint, uint8, uint16, uint32, uint64, uintptr:
93 | return float64(rv.Uint()), nil
94 | case int, int8, int16, int32, int64:
95 | return float64(rv.Int()), nil
96 | case float32:
97 | // use fmt to fix float32 -> float64 precision loss
98 | // eg: cvt.Float64E(float32(8.31))
99 | return strconv.ParseFloat(fmt.Sprintf("%f", vv), 64)
100 | case float64:
101 | return vv, nil
102 | }
103 |
104 | return 0, errConvFail
105 | }
106 |
107 | // Float32 convert an interface to a float32 type, with default value
108 | func Float32(v interface{}, def ...float32) float32 {
109 | if v, err := Float32E(v); err == nil {
110 | return v
111 | }
112 |
113 | if len(def) > 0 {
114 | return def[0]
115 | }
116 |
117 | return 0
118 | }
119 |
120 | // Float32P convert and store in a new float32 value, and returns a pointer to it
121 | func Float32P(v interface{}, def ...float32) *float32 {
122 | i := Float32(v, def...)
123 | return &i
124 | }
125 |
126 | // Float32E convert an interface to a float32 type
127 | func Float32E(val interface{}) (float32, error) {
128 | v, e := convFloat64E(val)
129 | if e := catch("float32", val, e); e != nil {
130 | return 0, e
131 | }
132 | if v > math.MaxFloat32 {
133 | return 0, fmt.Errorf(formatOutOfLimitFloat, newErr(val, "float32"), float32(math.MaxFloat32))
134 | }
135 |
136 | return float32(v), nil
137 | }
138 |
--------------------------------------------------------------------------------
/doc/content/en/type/slice.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Slice
3 | weight: 60
4 | ---
5 |
6 |
7 | {{< toc >}}
8 |
9 | ## ColumnsE
10 | Return the values from a single column in the input array/slice/map of struct/map, `[]interface{}`.
11 |
12 | Like `array_column` in PHP.
13 |
14 | ```go
15 | // []interface{}{"D1", "D2", nil}
16 | cvt.ColumnsE([]map[string]interface{}{
17 | {"1": 111, "DDD": "D1"},
18 | {"2": 222, "DDD": "D2"},
19 | {"DDD": nil},
20 | }, "DDD")
21 |
22 | // test type
23 | type TestStructD struct {
24 | D1 int
25 | }
26 | type TestStructE struct {
27 | D1 int
28 | DD *TestStructD
29 | }
30 |
31 | // []interface{}{11, 22}
32 | cvt.ColumnsE(map[int]TestStructD{1: {11}, 2: {22}}, "D1")
33 |
34 | // []interface{}{1, 2}
35 | cvt.ColumnsE([]TestStructE{{D1: 1}, {D1: 2}}, "D1")
36 | ```
37 |
38 | ## KeysE
39 | Return the keys of map, or fields of struct, `[]interface{}`.
40 |
41 | ```go
42 | cvt.KeysE()
43 | // key of map
44 | cvt.KeysE(map[float64]float64{0.1: -0.1, -1.2: 1.2}) // []interface{}{-1.2, 0.1}
45 | cvt.KeysE(map[string]interface{}{"A": 1, "2": 2}) // []interface{}{"2", "A"}
46 | cvt.KeysE(map[int]map[string]interface{}{1: {"1": 111, "DDD": 12.3}, -2: {"2": 222, "DDD": "321"}, 3: {"DDD": nil}}) // []interface{}{-2, 1, 3}
47 |
48 | // field name of struct
49 | cvt.KeysE(struct{
50 | A string
51 | B int
52 | C float
53 | }{}) // []interface{}{"A", "B", "C"}
54 |
55 | type TestStructB {
56 | B int
57 | }
58 | cvt.KeysE(struct{
59 | A string
60 | TestStructB
61 | C float
62 | }{}) // []interface{}{"A", "B", "C"}
63 | ```
64 |
65 |
66 | ## Slice
67 | Reference method `SliceE`.
68 |
69 | ## SliceE
70 | Convert an interface to a `[]interface{}` type.
71 |
72 | ```go
73 | cvt.SliceE("hello") // []interface{}{'h', 'e', 'l', 'l', 'o'}
74 | cvt.SliceE([]byte("hey")) // []interface{}{byte('h'), byte('e'), byte('y')}
75 | cvt.SliceE([]int{1, 2, 3}) // []interface{}{1, 2, 3}
76 | cvt.SliceE([]string{"a", "b", "c"}) // []interface{}{"a", "b", "c"}
77 | cvt.SliceE(map[int]string{1: "111", 2: "222"}) // []interface{}{"111", "222"}
78 |
79 | // struct values
80 | type TestStruct struct {
81 | A int
82 | B string
83 | }
84 | cvt.SliceE(TestStruct{18,"jhon"}) // []interface{}{18, "jhon"}
85 | ```
86 |
87 |
88 | ## SliceInt
89 | Reference method `SliceIntE`.
90 |
91 | ## SliceIntE
92 | Convert an interface to a `[]int` type.
93 |
94 | ```go
95 | cvt.SliceIntE([]string{"1", "2", "3"}) // []int{1, 2, 3}
96 | cvt.SliceIntE(map[int]string{2: "222", 1: "111"}) // []int{111, 222}
97 | ```
98 |
99 | ## SliceInt64
100 | Reference method `SliceInt64E`.
101 |
102 | ## SliceInt64E
103 | Convert an interface to a `[]int64` type.
104 |
105 | ```go
106 | cvt.SliceInt64E([]string{"1", "2", "3"}) // []int64{1, 2, 3}
107 | cvt.SliceInt64E(map[int]string{2: "222", 1: "111"}) // []int64{111, 222}
108 | ```
109 |
110 |
111 | ## SliceFloat64
112 | Reference method `SliceFloat64E`.
113 |
114 | ## SliceFloat64E
115 | Convert an interface to a `[]float64` type.
116 |
117 | ```go
118 | cvt.SliceFloat64E([]string{"1", "2", "3"}) // []float64{1, 2, 3}
119 | cvt.SliceFloat64E(map[int]string{2: "222", 1: "111"}) // []float64{111, 222}
120 | ```
121 |
122 | ## SliceString
123 | Reference method `SliceStringE`.
124 |
125 | ## SliceStringE
126 | Convert an interface to a `[]string` type.
127 |
128 | ```go
129 | cvt.SliceStringE([]float64{1.1, 2.2, 3.0}) // []string{"1.1", "2.2", "3"}
130 | cvt.SliceStringE(map[int]string{2: "222", 1: "11.1"}) // []string{"11.1", "222"}
131 | ```
132 |
133 | > More case see unit: `slice_test.go`
134 |
135 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/brand.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
24 |
42 |
44 |
45 |
47 | image/svg+xml
48 |
50 |
51 |
52 |
53 |
54 |
59 |
64 |
71 |
72 |
75 |
81 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/layouts/partials/menu-filetree.html:
--------------------------------------------------------------------------------
1 | {{ $current := . }}
2 | {{ template "tree-nav" dict "sect" .Site.Home.Sections "current" $current }}
3 |
4 |
5 |
6 | {{ define "tree-nav" }}
7 | {{ $current := .current }}
8 |
9 |
10 |
98 | {{ end }}
99 |
--------------------------------------------------------------------------------
/doc/static/custom.css:
--------------------------------------------------------------------------------
1 | /* Global customization */
2 | /* @see https://geekdocs.de/features/theming/ */
3 |
4 | /* THEME COLOR */
5 |
6 | :root {
7 | --code-max-height: 60rem;
8 | }
9 |
10 | /* Light mode theming */
11 | :root,
12 | :root[color-theme="light"] {
13 | --header-background: #4ec58a;
14 | --header-font-color: #ffffff;
15 |
16 | --body-background: #ffffff;
17 | --body-font-color: #343a40;
18 |
19 | --mark-color: #ffab00;
20 |
21 | --button-background: #62cb97;
22 | --button-border-color: #4ec58a;
23 |
24 | --link-color: #518169;
25 | --link-color-visited: #c54e8a;
26 |
27 | --code-background: #f5f6f8;
28 | --code-accent-color: #e3e7eb;
29 | --code-accent-color-lite: #eff1f3;
30 | --code-font-color: #5f5f5f;
31 |
32 | --code-copy-background: #f5f6f8;
33 | --code-copy-font-color: #6b7784;
34 | --code-copy-border-color: #adb4bc;
35 | --code-copy-success-color: #00c853;
36 |
37 | --accent-color: #e9ecef;
38 | --accent-color-lite: #f8f9fa;
39 |
40 | --control-icons: #b2bac1;
41 |
42 | --footer-background: #2f333e;
43 | --footer-font-color: #ffffff;
44 | --footer-link-color: #ffcc5c;
45 | --footer-link-color-visited: #ffcc5c;
46 | }
47 |
48 | @media (prefers-color-scheme: light) {
49 | :root {
50 | --header-background: #4ec58a;
51 | --header-font-color: #ffffff;
52 |
53 | --body-background: #ffffff;
54 | --body-font-color: #343a40;
55 |
56 | --mark-color: #ffab00;
57 |
58 | --button-background: #62cb97;
59 | --button-border-color: #4ec58a;
60 |
61 | --link-color: #518169;
62 | --link-color-visited: #c54e8a;
63 |
64 | --code-background: #f5f6f8;
65 | --code-accent-color: #e3e7eb;
66 | --code-accent-color-lite: #eff1f3;
67 | --code-font-color: #5f5f5f;
68 |
69 | --code-copy-background: #f5f6f8;
70 | --code-copy-font-color: #6b7784;
71 | --code-copy-border-color: #adb4bc;
72 | --code-copy-success-color: #00c853;
73 |
74 | --accent-color: #e9ecef;
75 | --accent-color-lite: #f8f9fa;
76 |
77 | --control-icons: #b2bac1;
78 |
79 | --footer-background: #2f333e;
80 | --footer-font-color: #ffffff;
81 | --footer-link-color: #ffcc5c;
82 | --footer-link-color-visited: #ffcc5c;
83 | }
84 | }
85 |
86 | /* Dark mode theming */
87 | :root[color-theme="dark"] {
88 | --header-background: #4ec58a;
89 | --header-font-color: #ffffff;
90 |
91 | --body-background: #343a40;
92 | --body-font-color: #ced3d8;
93 |
94 | --mark-color: #ffab00;
95 |
96 | --button-background: #62cb97;
97 | --button-border-color: #4ec58a;
98 |
99 | --link-color: #7ac29e;
100 | --link-color-visited: #c27a9e;
101 |
102 | --code-background: #2f353a;
103 | --code-accent-color: #262b2f;
104 | --code-accent-color-lite: #2b3035;
105 | --code-font-color: #b9b9b9;
106 |
107 | --code-copy-background: #343a40;
108 | --code-copy-font-color: #6b7784;
109 | --code-copy-border-color: #6b7784;
110 | --code-copy-success-color: #37905c;
111 |
112 | --accent-color: #2b3035;
113 | --accent-color-lite: #2f353a;
114 |
115 | --control-icons: #b2bac1;
116 |
117 | --footer-background: #2f333e;
118 | --footer-font-color: #ffffff;
119 | --footer-link-color: #ffcc5c;
120 | --footer-link-color-visited: #ffcc5c;
121 | }
122 |
123 | @media (prefers-color-scheme: dark) {
124 | :root {
125 | --header-background: #4ec58a;
126 | --header-font-color: #ffffff;
127 |
128 | --body-background: #343a40;
129 | --body-font-color: #ced3d8;
130 |
131 | --mark-color: #ffab00;
132 |
133 | --button-background: #62cb97;
134 | --button-border-color: #4ec58a;
135 |
136 | --link-color: #7ac29e;
137 | --link-color-visited: #c27a9e;
138 |
139 | --code-background: #2f353a;
140 | --code-accent-color: #262b2f;
141 | --code-accent-color-lite: #2b3035;
142 | --code-font-color: #b9b9b9;
143 |
144 | --code-copy-background: #343a40;
145 | --code-copy-font-color: #6b7784;
146 | --code-copy-border-color: #6b7784;
147 | --code-copy-success-color: #37905c;
148 |
149 | --accent-color: #2b3035;
150 | --accent-color-lite: #2f353a;
151 |
152 | --control-icons: #b2bac1;
153 |
154 | --footer-background: #2f333e;
155 | --footer-font-color: #ffffff;
156 | --footer-link-color: #ffcc5c;
157 | --footer-link-color-visited: #ffcc5c;
158 | }
159 | }
160 |
161 | /* INDEX PAGE */
162 | #tabs-index-example-0 ~ .gdoc-tabs__content {
163 | text-align: left !important;
164 | }
165 |
--------------------------------------------------------------------------------
/time.go:
--------------------------------------------------------------------------------
1 | package cvt
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 | "time"
7 | )
8 |
9 | // TimeLocation default time location
10 | // you can change this for global location
11 | // if cvt < v0.2.7, Time() and TimeE() use time.Parse() to parse the time string, its default time.UTC
12 | // since cvt >= v0.2.7, add TimeInLocation() and TimeInLocationE() support,
13 | // add this variable to setting default time.Location
14 | var TimeLocation = time.UTC
15 |
16 | // Time convert an interface to a time.Time type, with default value
17 | func Time(v interface{}, def ...time.Time) time.Time {
18 | if v, err := TimeE(v); err == nil {
19 | return v
20 | }
21 |
22 | if len(def) > 0 {
23 | return def[0]
24 | }
25 |
26 | return time.Time{}
27 | }
28 |
29 | // TimeE convert an interface to a time.Time type
30 | func TimeE(val interface{}) (t time.Time, err error) {
31 | return TimeInLocationE(val, TimeLocation)
32 | }
33 |
34 | // TimeInLocation convert an interface to a time.Time type, with time.Location, with default
35 | func TimeInLocation(v interface{}, loc *time.Location, def ...time.Time) time.Time {
36 | if v, err := TimeInLocationE(v, loc); err == nil {
37 | return v
38 | }
39 |
40 | if len(def) > 0 {
41 | return def[0]
42 | }
43 |
44 | return time.Time{}
45 | }
46 |
47 | // TimeInLocationE convert an interface to a time.Time type, with time.Location, with error
48 | func TimeInLocationE(val interface{}, loc *time.Location) (t time.Time, err error) {
49 | if loc == nil {
50 | loc = TimeLocation
51 | }
52 |
53 | // direct type(for improve performance)
54 | switch vv := val.(type) {
55 | case nil:
56 | return
57 | case time.Time:
58 | return vv, nil
59 | case string:
60 | return parseDate(vv, loc)
61 | case time.Duration:
62 | return time.Unix(int64(vv)/1e9, int64(vv)%1e9), nil
63 | case int, int32, int64, uint, uint32, uint64:
64 | return time.Unix(Int64(vv), 0), nil
65 | case json.Number:
66 | // timestamp
67 | vvv, err := vv.Int64()
68 | if err == nil {
69 | return time.Unix(Int64(vvv), 0), nil
70 | }
71 | // time string
72 | return parseDate(vv.String(), loc)
73 | }
74 |
75 | // indirect type
76 | v, _ := Indirect(val)
77 | switch vv := v.(type) {
78 | case nil:
79 | return
80 | case time.Time:
81 | return vv, nil
82 | case string:
83 | return parseDate(vv, loc)
84 | case int, int32, int64, uint, uint32, uint64:
85 | return time.Unix(Int64(vv), 0), nil
86 | }
87 |
88 | // interface implements
89 | switch vv := val.(type) {
90 | case fmt.Stringer:
91 | return parseDate(vv.String(), loc)
92 | }
93 |
94 | return t, newErr(val, "time.Time")
95 | }
96 |
97 | // TimeFormats all supported time formats
98 | // you can add your custom time format
99 | var TimeFormats = []string{
100 | time.RFC3339,
101 | time.RFC1123Z,
102 | time.RFC1123,
103 | time.RFC822Z,
104 | time.RFC822,
105 | time.RFC850,
106 | time.ANSIC,
107 | time.UnixDate,
108 | time.RubyDate,
109 | time.Kitchen,
110 | time.Stamp,
111 | time.StampMilli,
112 | time.StampMicro,
113 | time.StampNano,
114 | "2006-01-02T15:04:05", // ISO8601 without timezone
115 | "Mon Jan 2 15:04:05 2006 -0700", // Git log date
116 | "2006-01-02 15:04:05.999999999 -0700 MST", // Time.String()
117 | "2006-01-02",
118 | "02 Jan 2006",
119 | "20060102", // date of int
120 | "20060102150405", // datetime of int
121 | "2006-01-02T15:04:05-0700", // RFC3339 without timezone hh:mm colon
122 | "2006-01-02 15:04:05 -07:00",
123 | "2006-01-02 15:04:05 -0700",
124 | "2006-01-02 15:04:05Z07:00", // RFC3339 without T
125 | "2006-01-02 15:04:05Z0700", // RFC3339 without T or timezone hh:mm colon
126 | "2006-01-02 15:04:05",
127 | "2006-01-02 15:04:05.000",
128 | "2006-01-02 15:04:05.000000",
129 | "2006-01-02 15:04:05.000000000",
130 | "2006.01.02",
131 | "2006.01.02 15:04:05",
132 | "2006.01.02 15:04:05.000",
133 | "2006.01.02 15:04:05.000000",
134 | "2006.01.02 15:04:05.000000000",
135 | "2006/01/02",
136 | "2006/01/02 15:04:05",
137 | "2006/01/02 15:04:05.000",
138 | "2006/01/02 15:04:05.000000",
139 | "2006/01/02 15:04:05.000000000",
140 | "2006年01月02日",
141 | "2006年01月02日 15:04:05",
142 | "2006年01月02日 15:04:05.000",
143 | "2006年01月02日 15:04:05.000000",
144 | "2006年01月02日 15:04:05.000000000",
145 | "2006年01月02日 15时04分05秒",
146 | }
147 |
148 | func parseDate(s string, loc *time.Location) (t time.Time, err error) {
149 | for _, dateType := range TimeFormats {
150 | if t, err = time.ParseInLocation(dateType, s, loc); err == nil {
151 | return
152 | }
153 | }
154 |
155 | return t, fmt.Errorf("unable to parse date: %s", s)
156 | }
157 |
--------------------------------------------------------------------------------
/map_test.go:
--------------------------------------------------------------------------------
1 | package cvt_test
2 |
3 | import (
4 | "fmt"
5 | "testing"
6 |
7 | "github.com/shockerli/cvt"
8 | )
9 |
10 | func TestStringMapE(t *testing.T) {
11 | tests := []struct {
12 | input interface{}
13 | expect map[string]interface{}
14 | isErr bool
15 | }{
16 | // JSON
17 | {`{"name":"cvt","age":3.21}`, map[string]interface{}{"name": "cvt", "age": 3.21}, false},
18 | {`{"name":"cvt","tag":"convert"}`, map[string]interface{}{"name": "cvt", "tag": "convert"}, false},
19 | {`{"name":"cvt","build":true}`, map[string]interface{}{"name": "cvt", "build": true}, false},
20 | {[]byte(`{"name":"cvt","build":true}`), map[string]interface{}{"name": "cvt", "build": true}, false},
21 | {AliasTypeString(`{"name":"cvt","build":true}`), map[string]interface{}{"name": "cvt", "build": true}, false},
22 | {AliasTypeBytes(`{"name":"cvt","build":true}`), map[string]interface{}{"name": "cvt", "build": true}, false},
23 |
24 | // Map
25 | {map[string]interface{}{}, map[string]interface{}{}, false},
26 | {map[string]interface{}{"name": "cvt", "age": 3.21}, map[string]interface{}{"name": "cvt", "age": 3.21}, false},
27 | {map[interface{}]interface{}{"name": "cvt", "age": 3.21}, map[string]interface{}{"name": "cvt", "age": 3.21}, false},
28 | {map[interface{}]interface{}{111: "cvt", "222": 3.21}, map[string]interface{}{"111": "cvt", "222": 3.21}, false},
29 |
30 | // Struct
31 | {struct {
32 | Name string
33 | Age int
34 | }{"cvt", 3}, map[string]interface{}{"Name": "cvt", "Age": 3}, false},
35 | {&struct {
36 | Name string
37 | Age int
38 | }{"cvt", 3}, map[string]interface{}{"Name": "cvt", "Age": 3}, false},
39 | {struct {
40 | A1 string
41 | TestStructC
42 | }{"a1", TestStructC{"c1"}}, map[string]interface{}{"A1": "a1", "C1": "c1"}, false},
43 | {struct {
44 | A1 string
45 | TestStructC
46 | C1 string
47 | }{"a1", TestStructC{"c1-1"}, "c1-2"}, map[string]interface{}{"A1": "a1", "C1": "c1-2"}, false},
48 | {struct {
49 | A1 string
50 | *TestStructC
51 | C1 string
52 | }{"a1", &TestStructC{"c1-1"}, "c1-2"}, map[string]interface{}{"A1": "a1", "C1": "c1-2"}, false},
53 | {struct {
54 | C1 string
55 | *TestStructC
56 | A1 string
57 | }{"c1-1", &TestStructC{"c1-2"}, "a1"}, map[string]interface{}{"A1": "a1", "C1": "c1-1"}, false},
58 | {struct {
59 | AliasTypeInt8
60 | }{5}, map[string]interface{}{"AliasTypeInt8": AliasTypeInt8(5)}, false},
61 | {struct {
62 | *AliasTypeInt
63 | }{&aliasTypeInt0}, map[string]interface{}{"AliasTypeInt": aliasTypeInt0}, false},
64 | {struct {
65 | *AliasTypeInt
66 | }{}, map[string]interface{}{}, false},
67 | {struct {
68 | *TestStructC
69 | }{}, map[string]interface{}{}, false},
70 |
71 | // errors
72 | {nil, nil, true},
73 | {"", nil, true},
74 | {"hello", nil, true},
75 | }
76 |
77 | for i, tt := range tests {
78 | msg := fmt.Sprintf(
79 | "i = %d, input[%+v], expect[%+v], isErr[%v]",
80 | i, tt.input, tt.expect, tt.isErr,
81 | )
82 |
83 | v, err := cvt.StringMapE(tt.input)
84 | if tt.isErr {
85 | assertError(t, err, "[HasErr] "+msg)
86 | continue
87 | }
88 |
89 | assertNoError(t, err, "[NoErr] "+msg)
90 | assertEqual(t, tt.expect, v, "[WithE] "+msg)
91 | }
92 | }
93 |
94 | func TestIntMapE(t *testing.T) {
95 | tests := []struct {
96 | input interface{}
97 | expect map[int]interface{}
98 | isErr bool
99 | }{
100 | // JSON
101 | {`{"1":"cvt","2":3.21}`, map[int]interface{}{1: "cvt", 2: 3.21}, false},
102 | {`{"1":"cvt","2":"convert"}`, map[int]interface{}{1: "cvt", 2: "convert"}, false},
103 | {`{"1":"cvt","2":true}`, map[int]interface{}{1: "cvt", 2: true}, false},
104 | {[]byte(`{"1":"cvt","2":true}`), map[int]interface{}{1: "cvt", 2: true}, false},
105 | {AliasTypeString(`{"1":"cvt","2":true}`), map[int]interface{}{1: "cvt", 2: true}, false},
106 | {AliasTypeBytes(`{"1":"cvt","2":true}`), map[int]interface{}{1: "cvt", 2: true}, false},
107 |
108 | // Map
109 | {map[int]interface{}{}, map[int]interface{}{}, false},
110 | {map[int]interface{}{1: "cvt", 2: 3.21}, map[int]interface{}{1: "cvt", 2: 3.21}, false},
111 | {map[interface{}]interface{}{1: "cvt", 2: 3.21}, map[int]interface{}{1: "cvt", 2: 3.21}, false},
112 | {map[interface{}]interface{}{"1": "cvt", "2": 3.21}, map[int]interface{}{1: "cvt", 2: 3.21}, false},
113 |
114 | // errors
115 | {nil, nil, true},
116 | {map[interface{}]interface{}{"name": "cvt", 3.21: 3.21}, map[int]interface{}{1: "cvt", 2: 3.21}, true},
117 | {"", nil, true},
118 | {"hello", nil, true},
119 | }
120 |
121 | for i, tt := range tests {
122 | msg := fmt.Sprintf(
123 | "i = %d, input[%+v], expect[%+v], isErr[%v]",
124 | i, tt.input, tt.expect, tt.isErr,
125 | )
126 |
127 | v, err := cvt.IntMapE(tt.input)
128 | if tt.isErr {
129 | assertError(t, err, "[HasErr] "+msg)
130 | continue
131 | }
132 |
133 | assertNoError(t, err, "[NoErr] "+msg)
134 | assertEqual(t, tt.expect, v, "[WithE] "+msg)
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/doc/themes/hugo-geekdoc/static/js/katex-8d0741cb.bundle.min.js:
--------------------------------------------------------------------------------
1 | !function(){"use strict";var t,e,o,n,r={2657:function(t,e,o){o.p,document.addEventListener("DOMContentLoaded",(function(){o.e(116).then(o.t.bind(o,2116,23)).then((({default:t})=>{t(document.body)})).catch((t=>console.error(t)))}))},3491:function(t,e,o){t.exports=o.p+"fonts/KaTeX_AMS-Regular.woff"},5537:function(t,e,o){t.exports=o.p+"fonts/KaTeX_AMS-Regular.woff2"},282:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Caligraphic-Bold.woff"},4842:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Caligraphic-Bold.woff2"},1420:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Caligraphic-Regular.woff"},5148:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Caligraphic-Regular.woff2"},3873:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Fraktur-Bold.woff"},7925:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Fraktur-Bold.woff2"},7206:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Fraktur-Regular.woff"},1872:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Fraktur-Regular.woff2"},7888:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Main-Bold.woff"},7823:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Main-Bold.woff2"},6062:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Main-BoldItalic.woff"},8216:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Main-BoldItalic.woff2"},1411:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Main-Italic.woff"},4968:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Main-Italic.woff2"},9430:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Main-Regular.woff"},556:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Main-Regular.woff2"},2379:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Math-BoldItalic.woff"},7312:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Math-BoldItalic.woff2"},8212:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Math-Italic.woff"},621:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Math-Italic.woff2"},3958:function(t,e,o){t.exports=o.p+"fonts/KaTeX_SansSerif-Bold.woff"},8516:function(t,e,o){t.exports=o.p+"fonts/KaTeX_SansSerif-Bold.woff2"},208:function(t,e,o){t.exports=o.p+"fonts/KaTeX_SansSerif-Italic.woff"},9471:function(t,e,o){t.exports=o.p+"fonts/KaTeX_SansSerif-Italic.woff2"},9229:function(t,e,o){t.exports=o.p+"fonts/KaTeX_SansSerif-Regular.woff"},4671:function(t,e,o){t.exports=o.p+"fonts/KaTeX_SansSerif-Regular.woff2"},2629:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Script-Regular.woff"},9875:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Script-Regular.woff2"},8493:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Size1-Regular.woff"},2986:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Size1-Regular.woff2"},8398:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Size2-Regular.woff"},4118:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Size2-Regular.woff2"},498:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Size3-Regular.woff"},8932:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Size3-Regular.woff2"},8718:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Size4-Regular.woff"},7633:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Size4-Regular.woff2"},2422:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Typewriter-Regular.woff"},4313:function(t,e,o){t.exports=o.p+"fonts/KaTeX_Typewriter-Regular.woff2"}},f={};function i(t){var e=f[t];if(void 0!==e)return e.exports;var o=f[t]={exports:{}};return r[t].call(o.exports,o,o.exports,i),o.exports}i.m=r,e=Object.getPrototypeOf?function(t){return Object.getPrototypeOf(t)}:function(t){return t.__proto__},i.t=function(o,n){if(1&n&&(o=this(o)),8&n)return o;if("object"==typeof o&&o){if(4&n&&o.__esModule)return o;if(16&n&&"function"==typeof o.then)return o}var r=Object.create(null);i.r(r);var f={};t=t||[null,e({}),e([]),e(e)];for(var a=2&n&&o;"object"==typeof a&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach((function(t){f[t]=function(){return o[t]}}));return f.default=function(){return o},i.d(r,f),r},i.d=function(t,e){for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.f={},i.e=function(t){return Promise.all(Object.keys(i.f).reduce((function(e,o){return i.f[o](t,e),e}),[]))},i.u=function(t){return"js/"+t+"-9febb0f9.chunk.min.js"},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o={},n="geekdoc:",i.l=function(t,e,r,f){if(o[t])o[t].push(e);else{var a,u;if(void 0!==r)for(var c=document.getElementsByTagName("script"),s=0;s 0 {
15 | return def[0]
16 | }
17 |
18 | return nil
19 | }
20 |
21 | // SliceE convert an interface to a []interface{} type
22 | func SliceE(val interface{}) (sl []interface{}, err error) {
23 | if val == nil {
24 | return sl, errUnsupportedTypeNil
25 | }
26 |
27 | _, rv := Indirect(val)
28 |
29 | switch rv.Kind() {
30 | case reflect.String:
31 | var length = rv.Len()
32 | if length > 0 {
33 | sl = make([]interface{}, length)
34 | for j, vvv := range rv.String() {
35 | sl[j] = vvv
36 | }
37 | }
38 | case reflect.Slice, reflect.Array:
39 | var length = rv.Len()
40 | if length > 0 {
41 | sl = make([]interface{}, length)
42 | for j := 0; j < length; j++ {
43 | sl[j] = rv.Index(j).Interface()
44 | }
45 | }
46 | case reflect.Map:
47 | var length = rv.Len()
48 | if length > 0 {
49 | sl = make([]interface{}, length)
50 | for j, key := range sortedMapKeys(rv) {
51 | sl[j] = rv.MapIndex(key).Interface()
52 | }
53 | }
54 | case reflect.Struct:
55 | sl = deepStructValues(rv)
56 | default:
57 | err = newErr(val, "slice")
58 | }
59 | return
60 | }
61 |
62 | // SliceInt convert an interface to a []int type, with default value
63 | func SliceInt(v interface{}, def ...[]int) []int {
64 | if v, err := SliceIntE(v); err == nil {
65 | return v
66 | }
67 |
68 | if len(def) > 0 {
69 | return def[0]
70 | }
71 |
72 | return nil
73 | }
74 |
75 | // SliceIntE convert an interface to a []int type
76 | func SliceIntE(val interface{}) (sl []int, err error) {
77 | list, err := SliceE(val)
78 | if err != nil {
79 | return
80 | }
81 |
82 | if len(list) > 0 {
83 | var vv int
84 | sl = make([]int, len(list))
85 | for j, v := range list {
86 | vv, err = IntE(v)
87 | if err != nil {
88 | return
89 | }
90 | sl[j] = vv
91 | }
92 | }
93 |
94 | return
95 | }
96 |
97 | // SliceInt64 convert an interface to a []int64 type, with default value
98 | func SliceInt64(v interface{}, def ...[]int64) []int64 {
99 | if v, err := SliceInt64E(v); err == nil {
100 | return v
101 | }
102 |
103 | if len(def) > 0 {
104 | return def[0]
105 | }
106 |
107 | return nil
108 | }
109 |
110 | // SliceInt64E convert an interface to a []int64 type
111 | func SliceInt64E(val interface{}) (sl []int64, err error) {
112 | list, err := SliceE(val)
113 | if err != nil {
114 | return
115 | }
116 |
117 | if len(list) > 0 {
118 | var vv int64
119 | sl = make([]int64, len(list))
120 | for j, v := range list {
121 | vv, err = Int64E(v)
122 | if err != nil {
123 | return
124 | }
125 | sl[j] = vv
126 | }
127 | }
128 |
129 | return
130 | }
131 |
132 | // SliceFloat64 convert an interface to a []float64 type, with default value
133 | func SliceFloat64(v interface{}, def ...[]float64) []float64 {
134 | if v, err := SliceFloat64E(v); err == nil {
135 | return v
136 | }
137 |
138 | if len(def) > 0 {
139 | return def[0]
140 | }
141 |
142 | return nil
143 | }
144 |
145 | // SliceFloat64E convert an interface to a []float64 type
146 | func SliceFloat64E(val interface{}) (sl []float64, err error) {
147 | list, err := SliceE(val)
148 | if err != nil {
149 | return
150 | }
151 |
152 | if len(list) > 0 {
153 | var vv float64
154 | sl = make([]float64, len(list))
155 | for j, v := range list {
156 | vv, err = Float64E(v)
157 | if err != nil {
158 | return
159 | }
160 | sl[j] = vv
161 | }
162 | }
163 |
164 | return
165 | }
166 |
167 | // SliceString convert an interface to a []string type, with default value
168 | func SliceString(v interface{}, def ...[]string) []string {
169 | if v, err := SliceStringE(v); err == nil {
170 | return v
171 | }
172 |
173 | if len(def) > 0 {
174 | return def[0]
175 | }
176 |
177 | return nil
178 | }
179 |
180 | // SliceStringE convert an interface to a []string type
181 | func SliceStringE(val interface{}) (sl []string, err error) {
182 | list, err := SliceE(val)
183 | if err != nil {
184 | return
185 | }
186 |
187 | if len(list) > 0 {
188 | var vv string
189 | sl = make([]string, len(list))
190 | for j, v := range list {
191 | vv, err = StringE(v)
192 | if err != nil {
193 | return
194 | }
195 | sl[j] = vv
196 | }
197 | }
198 |
199 | return
200 | }
201 |
202 | // ColumnsE return the values from a single column in the input array/slice/map of struct/map
203 | func ColumnsE(val interface{}, field interface{}) (sl []interface{}, err error) {
204 | if val == nil {
205 | return nil, errUnsupportedTypeNil
206 | }
207 |
208 | _, rv := Indirect(val)
209 |
210 | switch rv.Kind() {
211 | case reflect.Slice, reflect.Array:
212 | var vv interface{}
213 | for j := 0; j < rv.Len(); j++ {
214 | vv, err = FieldE(rv.Index(j).Interface(), field)
215 | if err != nil {
216 | return nil, fmt.Errorf("unsupported type: %s", rv.Type().String())
217 | }
218 | sl = append(sl, vv)
219 | }
220 | case reflect.Map:
221 | var vv interface{}
222 | for _, key := range sortedMapKeys(rv) {
223 | vv, err = FieldE(rv.MapIndex(key).Interface(), field)
224 | if err != nil {
225 | return nil, fmt.Errorf("unsupported type: %s", rv.Type().String())
226 | }
227 | sl = append(sl, vv)
228 | }
229 | default:
230 | return nil, fmt.Errorf("unsupported type: %s", rv.Type().String())
231 | }
232 |
233 | return
234 | }
235 |
236 | // KeysE return the keys of map, sorted by asc; or fields of struct
237 | func KeysE(val interface{}) (sl []interface{}, err error) {
238 | if val == nil {
239 | return nil, errUnsupportedTypeNil
240 | }
241 |
242 | _, rv := Indirect(val)
243 |
244 | switch rv.Kind() {
245 | case reflect.Map:
246 | var length = rv.Len()
247 | if length > 0 {
248 | sl = make([]interface{}, length)
249 | for j, key := range sortedMapKeys(rv) {
250 | sl[j] = key.Interface()
251 | }
252 | }
253 | case reflect.Struct:
254 | fs := deepStructFields(rv.Type())
255 | if len(fs) > 0 {
256 | sl = make([]interface{}, len(fs))
257 | for j, v := range fs {
258 | sl[j] = v
259 | }
260 | }
261 | default:
262 | err = fmt.Errorf("unsupported type: %s", rv.Type().Name())
263 | }
264 |
265 | return
266 | }
267 |
--------------------------------------------------------------------------------