...

Text file src/github.com/pelletier/go-toml/v2/benchmark/benchmark.toml

Documentation: github.com/pelletier/go-toml/v2/benchmark

     1################################################################################
     2## Comment
     3
     4# Speak your mind with the hash symbol. They go from the symbol to the end of
     5# the line.
     6
     7
     8################################################################################
     9## Table
    10
    11# Tables (also known as hash tables or dictionaries) are collections of
    12# key/value pairs. They appear in square brackets on a line by themselves.
    13
    14[table]
    15
    16key = "value" # Yeah, you can do this.
    17
    18# Nested tables are denoted by table names with dots in them. Name your tables
    19# whatever crap you please, just don't use #, ., [ or ].
    20
    21[table.subtable]
    22
    23key = "another value"
    24
    25# You don't need to specify all the super-tables if you don't want to. TOML
    26# knows how to do it for you.
    27
    28# [x] you
    29# [x.y] don't
    30# [x.y.z] need these
    31[x.y.z.w] # for this to work
    32
    33
    34################################################################################
    35## Inline Table
    36
    37# Inline tables provide a more compact syntax for expressing tables. They are
    38# especially useful for grouped data that can otherwise quickly become verbose.
    39# Inline tables are enclosed in curly braces `{` and `}`. No newlines are
    40# allowed between the curly braces unless they are valid within a value.
    41
    42[table.inline]
    43
    44name = { first = "Tom", last = "Preston-Werner" }
    45point = { x = 1, y = 2 }
    46
    47
    48################################################################################
    49## String
    50
    51# There are four ways to express strings: basic, multi-line basic, literal, and
    52# multi-line literal. All strings must contain only valid UTF-8 characters.
    53
    54[string.basic]
    55
    56basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
    57
    58[string.multiline]
    59
    60# The following strings are byte-for-byte equivalent:
    61key1 = "One\nTwo"
    62key2 = """One\nTwo"""
    63key3 = """
    64One
    65Two"""
    66
    67[string.multiline.continued]
    68
    69# The following strings are byte-for-byte equivalent:
    70key1 = "The quick brown fox jumps over the lazy dog."
    71
    72key2 = """
    73The quick brown \
    74
    75
    76  fox jumps over \
    77    the lazy dog."""
    78
    79key3 = """\
    80       The quick brown \
    81       fox jumps over \
    82       the lazy dog.\
    83       """
    84
    85[string.literal]
    86
    87# What you see is what you get.
    88winpath  = 'C:\Users\nodejs\templates'
    89winpath2 = '\\ServerX\admin$\system32\'
    90quoted   = 'Tom "Dubs" Preston-Werner'
    91regex    = '<\i\c*\s*>'
    92
    93
    94[string.literal.multiline]
    95
    96regex2 = '''I [dw]on't need \d{2} apples'''
    97lines  = '''
    98The first newline is
    99trimmed in raw strings.
   100   All other whitespace
   101   is preserved.
   102'''
   103
   104
   105################################################################################
   106## Integer
   107
   108# Integers are whole numbers. Positive numbers may be prefixed with a plus sign.
   109# Negative numbers are prefixed with a minus sign.
   110
   111[integer]
   112
   113key1 = +99
   114key2 = 42
   115key3 = 0
   116key4 = -17
   117
   118[integer.underscores]
   119
   120# For large numbers, you may use underscores to enhance readability. Each
   121# underscore must be surrounded by at least one digit.
   122key1 = 1_000
   123key2 = 5_349_221
   124key3 = 1_2_3_4_5     # valid but inadvisable
   125
   126
   127################################################################################
   128## Float
   129
   130# A float consists of an integer part (which may be prefixed with a plus or
   131# minus sign) followed by a fractional part and/or an exponent part.
   132
   133[float.fractional]
   134
   135key1 = +1.0
   136key2 = 3.1415
   137key3 = -0.01
   138
   139[float.exponent]
   140
   141key1 = 5e+22
   142key2 = 1e6
   143key3 = -2E-2
   144
   145[float.both]
   146
   147key = 6.626e-34
   148
   149[float.underscores]
   150
   151key1 = 9_224_617.445_991_228_313
   152key2 = 1e1_00
   153
   154
   155################################################################################
   156## Boolean
   157
   158# Booleans are just the tokens you're used to. Always lowercase.
   159
   160[boolean]
   161
   162True = true
   163False = false
   164
   165
   166################################################################################
   167## Datetime
   168
   169# Datetimes are RFC 3339 dates.
   170
   171[datetime]
   172
   173key1 = 1979-05-27T07:32:00Z
   174key2 = 1979-05-27T00:32:00-07:00
   175key3 = 1979-05-27T00:32:00.999999-07:00
   176
   177
   178################################################################################
   179## Array
   180
   181# Arrays are square brackets with other primitives inside. Whitespace is
   182# ignored. Elements are separated by commas. Data types may not be mixed.
   183
   184[array]
   185
   186key1 = [ 1, 2, 3 ]
   187key2 = [ "red", "yellow", "green" ]
   188key3 = [ [ 1, 2 ], [3, 4, 5] ]
   189key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok
   190
   191# Arrays can also be multiline. So in addition to ignoring whitespace, arrays
   192# also ignore newlines between the brackets.  Terminating commas are ok before
   193# the closing bracket.
   194
   195key5 = [
   196  1, 2, 3
   197]
   198key6 = [
   199  1,
   200  2, # this is ok
   201]
   202
   203
   204################################################################################
   205## Array of Tables
   206
   207# These can be expressed by using a table name in double brackets. Each table
   208# with the same double bracketed name will be an element in the array. The
   209# tables are inserted in the order encountered.
   210
   211[[products]]
   212
   213name = "Hammer"
   214sku = 738594937
   215
   216[[products]]
   217
   218[[products]]
   219
   220name = "Nail"
   221sku = 284758393
   222color = "gray"
   223
   224
   225# You can create nested arrays of tables as well.
   226
   227[[fruit]]
   228  name = "apple"
   229
   230  [fruit.physical]
   231    color = "red"
   232    shape = "round"
   233
   234  [[fruit.variety]]
   235    name = "red delicious"
   236
   237  [[fruit.variety]]
   238    name = "granny smith"
   239
   240[[fruit]]
   241  name = "banana"
   242
   243  [[fruit.variety]]
   244    name = "plantain"

View as plain text