├── .gitignore ├── .whitesource ├── CNAME ├── Gemfile ├── LICENSE ├── _config.yml ├── _data └── nav.yml ├── _includes ├── browser-upgrade.html ├── head.html └── leftnav.html ├── _layouts └── article.html ├── accessing.md ├── connection-pool.md ├── css ├── bootstrap-responsive.min.css ├── bootstrap.min.css ├── godoc.css ├── journal.min.css ├── manual.css ├── prettify.css └── site.css ├── errors.md ├── importing.md ├── index.md ├── js ├── godoc.js ├── lang-go-rich.js └── prettify.js ├── modifying.md ├── nulls.md ├── overview.md ├── prepared.md ├── references.md ├── retrieving.md ├── surprises.md └── varcols.md /.gitignore: -------------------------------------------------------------------------------- 1 | .Gemfile.lock 2 | Gemfile.lock 3 | _site/ 4 | -------------------------------------------------------------------------------- /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "settingsInheritedFrom": "VividCortex/whitesource-config@master" 3 | } -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | go-database-sql.org 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'github-pages' 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More_considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-ShareAlike 4.0 International Public 58 | License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-ShareAlike 4.0 International Public License ("Public 63 | License"). To the extent this Public License may be interpreted as a 64 | contract, You are granted the Licensed Rights in consideration of Your 65 | acceptance of these terms and conditions, and the Licensor grants You 66 | such rights in consideration of benefits the Licensor receives from 67 | making the Licensed Material available under these terms and 68 | conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. Share means to provide material to the public by any means or 126 | process that requires permission under the Licensed Rights, such 127 | as reproduction, public display, public performance, distribution, 128 | dissemination, communication, or importation, and to make material 129 | available to the public including in ways that members of the 130 | public may access the material from a place and at a time 131 | individually chosen by them. 132 | 133 | l. Sui Generis Database Rights means rights other than copyright 134 | resulting from Directive 96/9/EC of the European Parliament and of 135 | the Council of 11 March 1996 on the legal protection of databases, 136 | as amended and/or succeeded, as well as other essentially 137 | equivalent rights anywhere in the world. 138 | 139 | m. You means the individual or entity exercising the Licensed Rights 140 | under this Public License. Your has a corresponding meaning. 141 | 142 | 143 | Section 2 -- Scope. 144 | 145 | a. License grant. 146 | 147 | 1. Subject to the terms and conditions of this Public License, 148 | the Licensor hereby grants You a worldwide, royalty-free, 149 | non-sublicensable, non-exclusive, irrevocable license to 150 | exercise the Licensed Rights in the Licensed Material to: 151 | 152 | a. reproduce and Share the Licensed Material, in whole or 153 | in part; and 154 | 155 | b. produce, reproduce, and Share Adapted Material. 156 | 157 | 2. Exceptions and Limitations. For the avoidance of doubt, where 158 | Exceptions and Limitations apply to Your use, this Public 159 | License does not apply, and You do not need to comply with 160 | its terms and conditions. 161 | 162 | 3. Term. The term of this Public License is specified in Section 163 | 6(a). 164 | 165 | 4. Media and formats; technical modifications allowed. The 166 | Licensor authorizes You to exercise the Licensed Rights in 167 | all media and formats whether now known or hereafter created, 168 | and to make technical modifications necessary to do so. The 169 | Licensor waives and/or agrees not to assert any right or 170 | authority to forbid You from making technical modifications 171 | necessary to exercise the Licensed Rights, including 172 | technical modifications necessary to circumvent Effective 173 | Technological Measures. For purposes of this Public License, 174 | simply making modifications authorized by this Section 2(a) 175 | (4) never produces Adapted Material. 176 | 177 | 5. Downstream recipients. 178 | 179 | a. Offer from the Licensor -- Licensed Material. Every 180 | recipient of the Licensed Material automatically 181 | receives an offer from the Licensor to exercise the 182 | Licensed Rights under the terms and conditions of this 183 | Public License. 184 | 185 | b. Additional offer from the Licensor -- Adapted Material. 186 | Every recipient of Adapted Material from You 187 | automatically receives an offer from the Licensor to 188 | exercise the Licensed Rights in the Adapted Material 189 | under the conditions of the Adapter's License You apply. 190 | 191 | c. No downstream restrictions. You may not offer or impose 192 | any additional or different terms or conditions on, or 193 | apply any Effective Technological Measures to, the 194 | Licensed Material if doing so restricts exercise of the 195 | Licensed Rights by any recipient of the Licensed 196 | Material. 197 | 198 | 6. No endorsement. Nothing in this Public License constitutes or 199 | may be construed as permission to assert or imply that You 200 | are, or that Your use of the Licensed Material is, connected 201 | with, or sponsored, endorsed, or granted official status by, 202 | the Licensor or others designated to receive attribution as 203 | provided in Section 3(a)(1)(A)(i). 204 | 205 | b. Other rights. 206 | 207 | 1. Moral rights, such as the right of integrity, are not 208 | licensed under this Public License, nor are publicity, 209 | privacy, and/or other similar personality rights; however, to 210 | the extent possible, the Licensor waives and/or agrees not to 211 | assert any such rights held by the Licensor to the limited 212 | extent necessary to allow You to exercise the Licensed 213 | Rights, but not otherwise. 214 | 215 | 2. Patent and trademark rights are not licensed under this 216 | Public License. 217 | 218 | 3. To the extent possible, the Licensor waives any right to 219 | collect royalties from You for the exercise of the Licensed 220 | Rights, whether directly or through a collecting society 221 | under any voluntary or waivable statutory or compulsory 222 | licensing scheme. In all other cases the Licensor expressly 223 | reserves any right to collect such royalties. 224 | 225 | 226 | Section 3 -- License Conditions. 227 | 228 | Your exercise of the Licensed Rights is expressly made subject to the 229 | following conditions. 230 | 231 | a. Attribution. 232 | 233 | 1. If You Share the Licensed Material (including in modified 234 | form), You must: 235 | 236 | a. retain the following if it is supplied by the Licensor 237 | with the Licensed Material: 238 | 239 | i. identification of the creator(s) of the Licensed 240 | Material and any others designated to receive 241 | attribution, in any reasonable manner requested by 242 | the Licensor (including by pseudonym if 243 | designated); 244 | 245 | ii. a copyright notice; 246 | 247 | iii. a notice that refers to this Public License; 248 | 249 | iv. a notice that refers to the disclaimer of 250 | warranties; 251 | 252 | v. a URI or hyperlink to the Licensed Material to the 253 | extent reasonably practicable; 254 | 255 | b. indicate if You modified the Licensed Material and 256 | retain an indication of any previous modifications; and 257 | 258 | c. indicate the Licensed Material is licensed under this 259 | Public License, and include the text of, or the URI or 260 | hyperlink to, this Public License. 261 | 262 | 2. You may satisfy the conditions in Section 3(a)(1) in any 263 | reasonable manner based on the medium, means, and context in 264 | which You Share the Licensed Material. For example, it may be 265 | reasonable to satisfy the conditions by providing a URI or 266 | hyperlink to a resource that includes the required 267 | information. 268 | 269 | 3. If requested by the Licensor, You must remove any of the 270 | information required by Section 3(a)(1)(A) to the extent 271 | reasonably practicable. 272 | 273 | b. ShareAlike. 274 | 275 | In addition to the conditions in Section 3(a), if You Share 276 | Adapted Material You produce, the following conditions also apply. 277 | 278 | 1. The Adapter's License You apply must be a Creative Commons 279 | license with the same License Elements, this version or 280 | later, or a BY-SA Compatible License. 281 | 282 | 2. You must include the text of, or the URI or hyperlink to, the 283 | Adapter's License You apply. You may satisfy this condition 284 | in any reasonable manner based on the medium, means, and 285 | context in which You Share Adapted Material. 286 | 287 | 3. You may not offer or impose any additional or different terms 288 | or conditions on, or apply any Effective Technological 289 | Measures to, Adapted Material that restrict exercise of the 290 | rights granted under the Adapter's License You apply. 291 | 292 | 293 | Section 4 -- Sui Generis Database Rights. 294 | 295 | Where the Licensed Rights include Sui Generis Database Rights that 296 | apply to Your use of the Licensed Material: 297 | 298 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 299 | to extract, reuse, reproduce, and Share all or a substantial 300 | portion of the contents of the database; 301 | 302 | b. if You include all or a substantial portion of the database 303 | contents in a database in which You have Sui Generis Database 304 | Rights, then the database in which You have Sui Generis Database 305 | Rights (but not its individual contents) is Adapted Material, 306 | 307 | including for purposes of Section 3(b); and 308 | c. You must comply with the conditions in Section 3(a) if You Share 309 | all or a substantial portion of the contents of the database. 310 | 311 | For the avoidance of doubt, this Section 4 supplements and does not 312 | replace Your obligations under this Public License where the Licensed 313 | Rights include other Copyright and Similar Rights. 314 | 315 | 316 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 317 | 318 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 319 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 320 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 321 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 322 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 323 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 324 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 325 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 326 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 327 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 328 | 329 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 330 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 331 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 332 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 333 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 334 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 335 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 336 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 337 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 338 | 339 | c. The disclaimer of warranties and limitation of liability provided 340 | above shall be interpreted in a manner that, to the extent 341 | possible, most closely approximates an absolute disclaimer and 342 | waiver of all liability. 343 | 344 | 345 | Section 6 -- Term and Termination. 346 | 347 | a. This Public License applies for the term of the Copyright and 348 | Similar Rights licensed here. However, if You fail to comply with 349 | this Public License, then Your rights under this Public License 350 | terminate automatically. 351 | 352 | b. Where Your right to use the Licensed Material has terminated under 353 | Section 6(a), it reinstates: 354 | 355 | 1. automatically as of the date the violation is cured, provided 356 | it is cured within 30 days of Your discovery of the 357 | violation; or 358 | 359 | 2. upon express reinstatement by the Licensor. 360 | 361 | For the avoidance of doubt, this Section 6(b) does not affect any 362 | right the Licensor may have to seek remedies for Your violations 363 | of this Public License. 364 | 365 | c. For the avoidance of doubt, the Licensor may also offer the 366 | Licensed Material under separate terms or conditions or stop 367 | distributing the Licensed Material at any time; however, doing so 368 | will not terminate this Public License. 369 | 370 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 371 | License. 372 | 373 | 374 | Section 7 -- Other Terms and Conditions. 375 | 376 | a. The Licensor shall not be bound by any additional or different 377 | terms or conditions communicated by You unless expressly agreed. 378 | 379 | b. Any arrangements, understandings, or agreements regarding the 380 | Licensed Material not stated herein are separate from and 381 | independent of the terms and conditions of this Public License. 382 | 383 | 384 | Section 8 -- Interpretation. 385 | 386 | a. For the avoidance of doubt, this Public License does not, and 387 | shall not be interpreted to, reduce, limit, restrict, or impose 388 | conditions on any use of the Licensed Material that could lawfully 389 | be made without permission under this Public License. 390 | 391 | b. To the extent possible, if any provision of this Public License is 392 | deemed unenforceable, it shall be automatically reformed to the 393 | minimum extent necessary to make it enforceable. If the provision 394 | cannot be reformed, it shall be severed from this Public License 395 | without affecting the enforceability of the remaining terms and 396 | conditions. 397 | 398 | c. No term or condition of this Public License will be waived and no 399 | failure to comply consented to unless expressly agreed to by the 400 | Licensor. 401 | 402 | d. Nothing in this Public License constitutes or may be interpreted 403 | as a limitation upon, or waiver of, any privileges and immunities 404 | that apply to the Licensor or You, including from the legal 405 | processes of any jurisdiction or authority. 406 | 407 | 408 | ======================================================================= 409 | 410 | Creative Commons is not a party to its public 411 | licenses. Notwithstanding, Creative Commons may elect to apply one of 412 | its public licenses to material it publishes and in those instances 413 | will be considered the “Licensor.” The text of the Creative Commons 414 | public licenses is dedicated to the public domain under the CC0 Public 415 | Domain Dedication. Except for the limited purpose of indicating that 416 | material is shared under a Creative Commons public license or as 417 | otherwise permitted by the Creative Commons policies published at 418 | creativecommons.org/policies, Creative Commons does not authorize the 419 | use of the trademark "Creative Commons" or any other trademark or logo 420 | of Creative Commons without its prior written consent including, 421 | without limitation, in connection with any unauthorized modifications 422 | to any of its public licenses or any other arrangements, 423 | understandings, or agreements concerning use of licensed material. For 424 | the avoidance of doubt, this paragraph does not form part of the 425 | public licenses. 426 | 427 | Creative Commons may be contacted at creativecommons.org. 428 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | title: Go database/sql tutorial 2 | description: Use database/sql effectively! 3 | safe: true 4 | lsi: false 5 | highlighter: rouge 6 | timezone: UTC 7 | markdown: kramdown 8 | -------------------------------------------------------------------------------- /_data/nav.yml: -------------------------------------------------------------------------------- 1 | docs: 2 | 3 | - title: Go database/sql tutorial 4 | url: index.html 5 | 6 | - title: Overview 7 | url: overview.html 8 | 9 | - title: Importing a Database Driver 10 | url: importing.html 11 | 12 | - title: Accessing the Database 13 | url: accessing.html 14 | 15 | - title: Retrieving Result Sets 16 | url: retrieving.html 17 | 18 | - title: Modifying Data and Using Transactions 19 | url: modifying.html 20 | 21 | - title: Using Prepared Statements 22 | url: prepared.html 23 | 24 | - title: Handling Errors 25 | url: errors.html 26 | 27 | - title: Working with NULLs 28 | url: nulls.html 29 | 30 | - title: Working with Unknown Columns 31 | url: varcols.html 32 | 33 | - title: The Connection Pool 34 | url: connection-pool.html 35 | 36 | - title: Surprises, Antipatterns and Limitations 37 | url: surprises.html 38 | 39 | - title: Related Reading and Resources 40 | url: references.html 41 | -------------------------------------------------------------------------------- /_includes/browser-upgrade.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_includes/head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {% if page.title %}{{ page.title }}{% else %}Go database/sql tutorial{% endif %} 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /_includes/leftnav.html: -------------------------------------------------------------------------------- 1 |
2 | 10 |
11 |
12 | Creative Commons License 13 |
14 |
15 | -------------------------------------------------------------------------------- /_layouts/article.html: -------------------------------------------------------------------------------- 1 | --- 2 | root: .. 3 | name: article 4 | nav: 5 | - 6 | name: Overview 7 | url: index.html 8 | articles: 9 | - 10 | title: Overview 11 | url: overview.html 12 | - 13 | title: Importing a Driver 14 | url: importing.html 15 | - 16 | title: Accessing a DB 17 | url: accessing.html 18 | - 19 | title: Getting Results 20 | url: retrieving.html 21 | - 22 | title: Updates and Transactions 23 | url: modifying.html 24 | - 25 | title: Prepared Statements 26 | url: prepared.html 27 | - 28 | title: Handling Errors 29 | url: errors.html 30 | - 31 | title: Working with NULLs 32 | url: nulls.html 33 | - 34 | title: Unknown Columns 35 | url: varcols.html 36 | - 37 | title: Connection Pooling 38 | url: connection-pool.html 39 | - 40 | title: Surprises and Limitations 41 | url: surprises.html 42 | - 43 | title: Resources 44 | url: references.html 45 | --- 46 | 47 | 48 | 49 | {% include head.html %} 50 | 51 | 52 | 53 | 54 | 55 |
56 |
57 |
58 | {% include leftnav.html %} 59 |
60 | 61 |
62 | 66 | {{ content }} 67 |
68 |
69 |
70 | 71 | 72 | -------------------------------------------------------------------------------- /accessing.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Accessing the Database 4 | --- 5 | 6 | Now that you've loaded the driver package, you're ready to create a database 7 | object, a `sql.DB`. 8 | 9 | To create a `sql.DB`, you use `sql.Open()`. This returns a `*sql.DB`: 10 | 11 |
12 | func main() {
13 | 	db, err := sql.Open("mysql",
14 | 		"user:password@tcp(127.0.0.1:3306)/hello")
15 | 	if err != nil {
16 | 		log.Fatal(err)
17 | 	}
18 | 	defer db.Close()
19 | }
20 | 
21 | 22 | In the example shown, we're illustrating several things: 23 | 24 | 1. The first argument to `sql.Open` is the driver name. This is the string that the driver used to register itself with `database/sql`, and is conventionally the same as the package name to avoid confusion. For example, it's `mysql` for [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql). Some drivers do not follow the convention and use the database name, e.g. `sqlite3` for [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) and `postgres` for [github.com/lib/pq](https://github.com/lib/pq). 25 | 2. The second argument is a driver-specific syntax that tells the driver how to access the underlying datastore. In this example, we're connecting to the "hello" database inside a local MySQL server instance. 26 | 3. You should (almost) always check and handle errors returned from all `database/sql` operations. There are a few special cases that we'll discuss later where it doesn't make sense to do this. 27 | 4. It is idiomatic to `defer db.Close()` if the `sql.DB` should not have a lifetime beyond the scope of the function. 28 | 29 | Perhaps counter-intuitively, `sql.Open()` **does not establish any connections 30 | to the database**, nor does it validate driver connection parameters. Instead, 31 | it simply prepares the database abstraction for later use. The first actual 32 | connection to the underlying datastore will be established lazily, when it's 33 | needed for the first time. If you want to check right away that the database is 34 | available and accessible (for example, check that you can establish a network 35 | connection and log in), use `db.Ping()` to do that, and remember to check for 36 | errors: 37 | 38 |
39 | err = db.Ping()
40 | if err != nil {
41 | 	// do something here
42 | }
43 | 
44 | 45 | Although it's idiomatic to `Close()` the database when you're finished with it, 46 | **the `sql.DB` object is designed to be long-lived.** Don't `Open()` and 47 | `Close()` databases frequently. Instead, create **one** `sql.DB` object for each 48 | distinct datastore you need to access, and keep it until the program is done 49 | accessing that datastore. Pass it around as needed, or make it available somehow 50 | globally, but keep it open. And don't `Open()` and `Close()` from a short-lived 51 | function. Instead, pass the `sql.DB` into that short-lived function as an 52 | argument. 53 | 54 | If you don't treat the `sql.DB` as a long-lived object, you could experience 55 | problems such as poor reuse and sharing of connections, running out of available 56 | network resources, or sporadic failures due to a lot of TCP connections 57 | remaining in `TIME_WAIT` status. Such problems are signs that you're not using 58 | `database/sql` as it was designed. 59 | 60 | Now it's time to use your `sql.DB` object. 61 | 62 | **Previous: [Importing a Database Driver](importing.html)** 63 | **Next: [Retrieving Result Sets](retrieving.html)** 64 | -------------------------------------------------------------------------------- /connection-pool.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: The Connection Pool 4 | --- 5 | 6 | There is a basic connection pool in the `database/sql` package. There isn't a 7 | lot of ability to control or inspect it, but here are some things you might find 8 | useful to know: 9 | 10 | * Connection pooling means that executing two consecutive statements on a single database might open two connections and execute them separately. It is fairly common for programmers to be confused as to why their code misbehaves. For example, `LOCK TABLES` followed by an `INSERT` can block because the `INSERT` is on a connection that does not hold the table lock. 11 | * Connections are created when needed and there isn't a free connection in the pool. 12 | * By default, there's no limit on the number of connections. If you try to do a lot of things at once, you can create an arbitrary number of connections. This can cause the database to return an error such as "too many connections." 13 | * In Go 1.1 or newer, you can use `db.SetMaxIdleConns(N)` to limit the number of *idle* connections in the pool. This doesn't limit the pool size, though. 14 | * In Go 1.2.1 or newer, you can use `db.SetMaxOpenConns(N)` to limit the number of *total* open connections to the database. Unfortunately, a [deadlock bug](https://groups.google.com/d/msg/golang-dev/jOTqHxI09ns/x79ajll-ab4J) ([fix](https://code.google.com/p/go/source/detail?r=8a7ac002f840)) prevents `db.SetMaxOpenConns(N)` from safely being used in 1.2. 15 | * Connections are recycled rather fast. Setting a high number of idle connections with `db.SetMaxIdleConns(N)` can reduce this churn, and help keep connections around for reuse. 16 | * Keeping a connection idle for a long time can cause problems (like in [this issue](https://github.com/go-sql-driver/mysql/issues/257) with MySQL on Microsoft Azure). Try `db.SetMaxIdleConns(0)` if you get connection timeouts because a connection is idle for too long. 17 | * You can also specify the maximum amount of time a connection may be reused by setting `db.SetConnMaxLifetime(duration)` since reusing long lived connections may cause network issues. This closes the unused connections lazily i.e. closing expired connection may be deferred. 18 | 19 | **Previous: [Working with Unknown Columns](varcols.html)** 20 | **Next: [Surprises, Antipatterns and Limitations](surprises.html)** 21 | -------------------------------------------------------------------------------- /css/bootstrap-responsive.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Responsive v2.0.3 3 | * 4 | * Copyright 2012 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | */.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}@media(max-width:767px){.visible-phone{display:inherit!important}.hidden-phone{display:none!important}.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}}@media(min-width:768px) and (max-width:979px){.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}}@media(max-width:480px){.nav-collapse{-webkit-transform:translate3d(0,0,0)}.page-header h1 small{display:block;line-height:18px}input[type="checkbox"],input[type="radio"]{border:1px solid #ccc}.form-horizontal .control-group>label{float:none;width:auto;padding-top:0;text-align:left}.form-horizontal .controls{margin-left:0}.form-horizontal .control-list{padding-top:0}.form-horizontal .form-actions{padding-right:10px;padding-left:10px}.modal{position:absolute;top:10px;right:10px;left:10px;width:auto;margin:0}.modal.fade.in{top:auto}.modal-header .close{padding:10px;margin:-10px}.carousel-caption{position:static}}@media(max-width:767px){body{padding-right:20px;padding-left:20px}.navbar-fixed-top,.navbar-fixed-bottom{margin-right:-20px;margin-left:-20px}.container-fluid{padding:0}.dl-horizontal dt{float:none;width:auto;clear:none;text-align:left}.dl-horizontal dd{margin-left:0}.container{width:auto}.row-fluid{width:100%}.row,.thumbnails{margin-left:0}[class*="span"],.row-fluid [class*="span"]{display:block;float:none;width:auto;margin-left:0}.input-large,.input-xlarge,.input-xxlarge,input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.input-prepend input,.input-append input,.input-prepend input[class*="span"],.input-append input[class*="span"]{display:inline-block;width:auto}}@media(min-width:768px) and (max-width:979px){.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:20px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:724px}.span12{width:724px}.span11{width:662px}.span10{width:600px}.span9{width:538px}.span8{width:476px}.span7{width:414px}.span6{width:352px}.span5{width:290px}.span4{width:228px}.span3{width:166px}.span2{width:104px}.span1{width:42px}.offset12{margin-left:764px}.offset11{margin-left:702px}.offset10{margin-left:640px}.offset9{margin-left:578px}.offset8{margin-left:516px}.offset7{margin-left:454px}.offset6{margin-left:392px}.offset5{margin-left:330px}.offset4{margin-left:268px}.offset3{margin-left:206px}.offset2{margin-left:144px}.offset1{margin-left:82px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.762430939%;*margin-left:2.709239449638298%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:99.999999993%;*width:99.9468085036383%}.row-fluid .span11{width:91.436464082%;*width:91.38327259263829%}.row-fluid .span10{width:82.87292817100001%;*width:82.8197366816383%}.row-fluid .span9{width:74.30939226%;*width:74.25620077063829%}.row-fluid .span8{width:65.74585634900001%;*width:65.6926648596383%}.row-fluid .span7{width:57.182320438000005%;*width:57.129128948638304%}.row-fluid .span6{width:48.618784527%;*width:48.5655930376383%}.row-fluid .span5{width:40.055248616%;*width:40.0020571266383%}.row-fluid .span4{width:31.491712705%;*width:31.4385212156383%}.row-fluid .span3{width:22.928176794%;*width:22.874985304638297%}.row-fluid .span2{width:14.364640883%;*width:14.311449393638298%}.row-fluid .span1{width:5.801104972%;*width:5.747913482638298%}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:714px}input.span11,textarea.span11,.uneditable-input.span11{width:652px}input.span10,textarea.span10,.uneditable-input.span10{width:590px}input.span9,textarea.span9,.uneditable-input.span9{width:528px}input.span8,textarea.span8,.uneditable-input.span8{width:466px}input.span7,textarea.span7,.uneditable-input.span7{width:404px}input.span6,textarea.span6,.uneditable-input.span6{width:342px}input.span5,textarea.span5,.uneditable-input.span5{width:280px}input.span4,textarea.span4,.uneditable-input.span4{width:218px}input.span3,textarea.span3,.uneditable-input.span3{width:156px}input.span2,textarea.span2,.uneditable-input.span2{width:94px}input.span1,textarea.span1,.uneditable-input.span1{width:32px}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:30px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.564102564%;*margin-left:2.510911074638298%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145300001%;*width:91.3997999636383%}.row-fluid .span10{width:82.905982906%;*width:82.8527914166383%}.row-fluid .span9{width:74.358974359%;*width:74.30578286963829%}.row-fluid .span8{width:65.81196581200001%;*width:65.7587743226383%}.row-fluid .span7{width:57.264957265%;*width:57.2117657756383%}.row-fluid .span6{width:48.717948718%;*width:48.6647572286383%}.row-fluid .span5{width:40.170940171000005%;*width:40.117748681638304%}.row-fluid .span4{width:31.623931624%;*width:31.5707401346383%}.row-fluid .span3{width:23.076923077%;*width:23.0237315876383%}.row-fluid .span2{width:14.529914530000001%;*width:14.4767230406383%}.row-fluid .span1{width:5.982905983%;*width:5.929714493638298%}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:1160px}input.span11,textarea.span11,.uneditable-input.span11{width:1060px}input.span10,textarea.span10,.uneditable-input.span10{width:960px}input.span9,textarea.span9,.uneditable-input.span9{width:860px}input.span8,textarea.span8,.uneditable-input.span8{width:760px}input.span7,textarea.span7,.uneditable-input.span7{width:660px}input.span6,textarea.span6,.uneditable-input.span6{width:560px}input.span5,textarea.span5,.uneditable-input.span5{width:460px}input.span4,textarea.span4,.uneditable-input.span4{width:360px}input.span3,textarea.span3,.uneditable-input.span3{width:260px}input.span2,textarea.span2,.uneditable-input.span2{width:160px}input.span1,textarea.span1,.uneditable-input.span1{width:60px}.thumbnails{margin-left:-30px}.thumbnails>li{margin-left:30px}.row-fluid .thumbnails{margin-left:0}}@media(max-width:979px){body{padding-top:0}.navbar-fixed-top{position:static;margin-bottom:18px}.navbar-fixed-top .navbar-inner{padding:5px}.navbar .container{width:auto;padding:0}.navbar .brand{padding-right:10px;padding-left:10px;margin:0 0 0 -5px}.nav-collapse{clear:both}.nav-collapse .nav{float:none;margin:0 0 9px}.nav-collapse .nav>li{float:none}.nav-collapse .nav>li>a{margin-bottom:2px}.nav-collapse .nav>.divider-vertical{display:none}.nav-collapse .nav .nav-header{color:#999;text-shadow:none}.nav-collapse .nav>li>a,.nav-collapse .dropdown-menu a{padding:6px 15px;font-weight:bold;color:#999;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.nav-collapse .btn{padding:4px 10px 4px;font-weight:normal;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-collapse .dropdown-menu li+li a{margin-bottom:2px}.nav-collapse .nav>li>a:hover,.nav-collapse .dropdown-menu a:hover{background-color:#222}.nav-collapse.in .btn-group{padding:0;margin-top:5px}.nav-collapse .dropdown-menu{position:static;top:auto;left:auto;display:block;float:none;max-width:none;padding:0;margin:0 15px;background-color:transparent;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.nav-collapse .dropdown-menu:before,.nav-collapse .dropdown-menu:after{display:none}.nav-collapse .dropdown-menu .divider{display:none}.nav-collapse .navbar-form,.nav-collapse .navbar-search{float:none;padding:9px 15px;margin:9px 0;border-top:1px solid #222;border-bottom:1px solid #222;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}.navbar .nav-collapse .nav.pull-right{float:none;margin-left:0}.nav-collapse,.nav-collapse.collapse{height:0;overflow:hidden}.navbar .btn-navbar{display:block}.navbar-static .navbar-inner{padding-right:10px;padding-left:10px}}@media(min-width:980px){.nav-collapse.collapse{height:auto!important;overflow:visible!important}} 10 | -------------------------------------------------------------------------------- /css/bootstrap.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v2.0.3 3 | * 4 | * Copyright 2012 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:20px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.127659574%;*margin-left:2.0744680846382977%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:99.99999998999999%;*width:99.94680850063828%}.row-fluid .span11{width:91.489361693%;*width:91.4361702036383%}.row-fluid .span10{width:82.97872339599999%;*width:82.92553190663828%}.row-fluid .span9{width:74.468085099%;*width:74.4148936096383%}.row-fluid .span8{width:65.95744680199999%;*width:65.90425531263828%}.row-fluid .span7{width:57.446808505%;*width:57.3936170156383%}.row-fluid .span6{width:48.93617020799999%;*width:48.88297871863829%}.row-fluid .span5{width:40.425531911%;*width:40.3723404216383%}.row-fluid .span4{width:31.914893614%;*width:31.8617021246383%}.row-fluid .span3{width:23.404255317%;*width:23.3510638276383%}.row-fluid .span2{width:14.89361702%;*width:14.8404255306383%}.row-fluid .span1{width:6.382978723%;*width:6.329787233638298%}.container{margin-right:auto;margin-left:auto;*zoom:1}.container:before,.container:after{display:table;content:""}.container:after{clear:both}.container-fluid{padding-right:20px;padding-left:20px;*zoom:1}.container-fluid:before,.container-fluid:after{display:table;content:""}.container-fluid:after{clear:both}p{margin:0 0 9px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px}p small{font-size:11px;color:#999}.lead{margin-bottom:18px;font-size:20px;font-weight:200;line-height:27px}h1,h2,h3,h4,h5,h6{margin:0;font-family:inherit;font-weight:bold;color:inherit;text-rendering:optimizelegibility}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;color:#999}h1{font-size:30px;line-height:36px}h1 small{font-size:18px}h2{font-size:24px;line-height:36px}h2 small{font-size:18px}h3{font-size:18px;line-height:27px}h3 small{font-size:14px}h4,h5,h6{line-height:18px}h4{font-size:14px}h4 small{font-size:12px}h5{font-size:12px}h6{font-size:11px;color:#999;text-transform:uppercase}.page-header{padding-bottom:17px;margin:18px 0;border-bottom:1px solid #eee}.page-header h1{line-height:1}ul,ol{padding:0;margin:0 0 9px 25px}ul ul,ul ol,ol ol,ol ul{margin-bottom:0}ul{list-style:disc}ol{list-style:decimal}li{line-height:18px}ul.unstyled,ol.unstyled{margin-left:0;list-style:none}dl{margin-bottom:18px}dt,dd{line-height:18px}dt{font-weight:bold;line-height:17px}dd{margin-left:9px}.dl-horizontal dt{float:left;width:120px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:130px}hr{margin:18px 0;border:0;border-top:1px solid #eee;border-bottom:1px solid #fff}strong{font-weight:bold}em{font-style:italic}.muted{color:#999}abbr[title]{cursor:help;border-bottom:1px dotted #ddd}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:0 0 0 15px;margin:0 0 18px;border-left:5px solid #eee}blockquote p{margin-bottom:0;font-size:16px;font-weight:300;line-height:22.5px}blockquote small{display:block;line-height:18px;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small{text-align:right}q:before,q:after,blockquote:before,blockquote:after{content:""}address{display:block;margin-bottom:18px;font-style:normal;line-height:18px}small{font-size:100%}cite{font-style:normal}code,pre{padding:0 3px 2px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:12px;color:#333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}code{padding:2px 4px;color:#d14;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{display:block;padding:8.5px;margin:0 0 9px;font-size:12.025px;line-height:18px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}pre.prettyprint{margin-bottom:18px}pre code{padding:0;color:inherit;background-color:transparent;border:0}.pre-scrollable{max-height:340px;overflow-y:scroll}form{margin:0 0 18px}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:27px;font-size:19.5px;line-height:36px;color:#333;border:0;border-bottom:1px solid #eee}legend small{font-size:13.5px;color:#999}label,input,button,select,textarea{font-size:13px;font-weight:normal;line-height:18px}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}label{display:block;margin-bottom:5px;color:#333}input,textarea,select,.uneditable-input{display:inline-block;width:210px;height:18px;padding:4px;margin-bottom:9px;font-size:13px;line-height:18px;color:#555;background-color:#fff;border:1px solid #ccc;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.uneditable-textarea{width:auto;height:auto}label input,label textarea,label select{display:block}input[type="image"],input[type="checkbox"],input[type="radio"]{width:auto;height:auto;padding:0;margin:3px 0;*margin-top:0;line-height:normal;cursor:pointer;background-color:transparent;border:0 \9;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}input[type="image"]{border:0}input[type="file"]{width:auto;padding:initial;line-height:initial;background-color:#fff;background-color:initial;border:initial;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}input[type="button"],input[type="reset"],input[type="submit"]{width:auto;height:auto}select,input[type="file"]{height:28px;*margin-top:4px;line-height:28px}input[type="file"]{line-height:18px \9}select{width:220px;background-color:#fff}select[multiple],select[size]{height:auto}input[type="image"]{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}textarea{height:auto}input[type="hidden"]{display:none}.radio,.checkbox{min-height:18px;padding-left:18px}.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-18px}.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px}.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle}.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px}input,textarea{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-ms-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s}input:focus,textarea:focus{border-color:rgba(82,168,236,0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)}input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus,select:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.input-mini{width:60px}.input-small{width:90px}.input-medium{width:150px}.input-large{width:210px}.input-xlarge{width:270px}.input-xxlarge{width:530px}input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:930px}input.span11,textarea.span11,.uneditable-input.span11{width:850px}input.span10,textarea.span10,.uneditable-input.span10{width:770px}input.span9,textarea.span9,.uneditable-input.span9{width:690px}input.span8,textarea.span8,.uneditable-input.span8{width:610px}input.span7,textarea.span7,.uneditable-input.span7{width:530px}input.span6,textarea.span6,.uneditable-input.span6{width:450px}input.span5,textarea.span5,.uneditable-input.span5{width:370px}input.span4,textarea.span4,.uneditable-input.span4{width:290px}input.span3,textarea.span3,.uneditable-input.span3{width:210px}input.span2,textarea.span2,.uneditable-input.span2{width:130px}input.span1,textarea.span1,.uneditable-input.span1{width:50px}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eee;border-color:#ddd}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent}.control-group.warning>label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853}.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853;border-color:#c09853}.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:0 0 6px #dbc59e;-moz-box-shadow:0 0 6px #dbc59e;box-shadow:0 0 6px #dbc59e}.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.control-group.error>label,.control-group.error .help-block,.control-group.error .help-inline{color:#b94a48}.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48;border-color:#b94a48}.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:0 0 6px #d59392;-moz-box-shadow:0 0 6px #d59392;box-shadow:0 0 6px #d59392}.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.control-group.success>label,.control-group.success .help-block,.control-group.success .help-inline{color:#468847}.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847;border-color:#468847}.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:0 0 6px #7aba7b;-moz-box-shadow:0 0 6px #7aba7b;box-shadow:0 0 6px #7aba7b}.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847}input:focus:required:invalid,textarea:focus:required:invalid,select:focus:required:invalid{color:#b94a48;border-color:#ee5f5b}input:focus:required:invalid:focus,textarea:focus:required:invalid:focus,select:focus:required:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.form-actions{padding:17px 20px 18px;margin-top:18px;margin-bottom:18px;background-color:#f5f5f5;border-top:1px solid #ddd;*zoom:1}.form-actions:before,.form-actions:after{display:table;content:""}.form-actions:after{clear:both}.uneditable-input{overflow:hidden;white-space:nowrap;cursor:not-allowed;background-color:#fff;border-color:#eee;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)}:-moz-placeholder{color:#999}::-webkit-input-placeholder{color:#999}.help-block,.help-inline{color:#555}.help-block{display:block;margin-bottom:9px}.help-inline{display:inline-block;*display:inline;padding-left:5px;vertical-align:middle;*zoom:1}.input-prepend,.input-append{margin-bottom:5px}.input-prepend input,.input-append input,.input-prepend select,.input-append select,.input-prepend .uneditable-input,.input-append .uneditable-input{position:relative;margin-bottom:0;*margin-left:0;vertical-align:middle;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-prepend input:focus,.input-append input:focus,.input-prepend select:focus,.input-append select:focus,.input-prepend .uneditable-input:focus,.input-append .uneditable-input:focus{z-index:2}.input-prepend .uneditable-input,.input-append .uneditable-input{border-left-color:#ccc}.input-prepend .add-on,.input-append .add-on{display:inline-block;width:auto;height:18px;min-width:16px;padding:4px 5px;font-weight:normal;line-height:18px;text-align:center;text-shadow:0 1px 0 #fff;vertical-align:middle;background-color:#eee;border:1px solid #ccc}.input-prepend .add-on,.input-append .add-on,.input-prepend .btn,.input-append .btn{margin-left:-1px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend .active,.input-append .active{background-color:#a9dba9;border-color:#46a546}.input-prepend .add-on,.input-prepend .btn{margin-right:-1px}.input-prepend .add-on:first-child,.input-prepend .btn:first-child{-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append input,.input-append select,.input-append .uneditable-input{-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append .uneditable-input{border-right-color:#ccc;border-left-color:#eee}.input-append .add-on:last-child,.input-append .btn:last-child{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-prepend.input-append input,.input-prepend.input-append select,.input-prepend.input-append .uneditable-input{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend.input-append .add-on:first-child,.input-prepend.input-append .btn:first-child{margin-right:-1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-prepend.input-append .add-on:last-child,.input-prepend.input-append .btn:last-child{margin-left:-1px;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.search-query{padding-right:14px;padding-right:4px \9;padding-left:14px;padding-left:4px \9;margin-bottom:0;-webkit-border-radius:14px;-moz-border-radius:14px;border-radius:14px}.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.form-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input,.form-search .input-prepend,.form-inline .input-prepend,.form-horizontal .input-prepend,.form-search .input-append,.form-inline .input-append,.form-horizontal .input-append{display:inline-block;*display:inline;margin-bottom:0;*zoom:1}.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none}.form-search label,.form-inline label{display:inline-block}.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{margin-bottom:0}.form-search .radio,.form-search .checkbox,.form-inline .radio,.form-inline .checkbox{padding-left:0;margin-bottom:0;vertical-align:middle}.form-search .radio input[type="radio"],.form-search .checkbox input[type="checkbox"],.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:left;margin-right:3px;margin-left:0}.control-group{margin-bottom:9px}legend+.control-group{margin-top:18px;-webkit-margin-top-collapse:separate}.form-horizontal .control-group{margin-bottom:18px;*zoom:1}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;content:""}.form-horizontal .control-group:after{clear:both}.form-horizontal .control-label{float:left;width:140px;padding-top:5px;text-align:right}.form-horizontal .controls{*display:inline-block;*padding-left:20px;margin-left:160px;*margin-left:0}.form-horizontal .controls:first-child{*padding-left:160px}.form-horizontal .help-block{margin-top:9px;margin-bottom:0}.form-horizontal .form-actions{padding-left:160px}table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0}.table{width:100%;margin-bottom:18px}.table th,.table td{padding:8px;line-height:18px;text-align:left;vertical-align:top;border-top:1px solid #ddd}.table th{font-weight:bold}.table thead th{vertical-align:bottom}.table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0}.table tbody+tbody{border-top:2px solid #ddd}.table-condensed th,.table-condensed td{padding:4px 5px}.table-bordered{border:1px solid #ddd;border-collapse:separate;*border-collapse:collapsed;border-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.table-bordered th,.table-bordered td{border-left:1px solid #ddd}.table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered colgroup+tbody tr:first-child td,.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0}.table-bordered thead:first-child tr:first-child th:first-child,.table-bordered tbody:first-child tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered thead:first-child tr:first-child th:last-child,.table-bordered tbody:first-child tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-bordered thead:last-child tr:last-child th:first-child,.table-bordered tbody:last-child tr:last-child td:first-child{-webkit-border-radius:0 0 0 4px;-moz-border-radius:0 0 0 4px;border-radius:0 0 0 4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px}.table-bordered thead:last-child tr:last-child th:last-child,.table-bordered tbody:last-child tr:last-child td:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px}.table-striped tbody tr:nth-child(odd) td,.table-striped tbody tr:nth-child(odd) th{background-color:#f9f9f9}.table tbody tr:hover td,.table tbody tr:hover th{background-color:#f5f5f5}table .span1{float:none;width:44px;margin-left:0}table .span2{float:none;width:124px;margin-left:0}table .span3{float:none;width:204px;margin-left:0}table .span4{float:none;width:284px;margin-left:0}table .span5{float:none;width:364px;margin-left:0}table .span6{float:none;width:444px;margin-left:0}table .span7{float:none;width:524px;margin-left:0}table .span8{float:none;width:604px;margin-left:0}table .span9{float:none;width:684px;margin-left:0}table .span10{float:none;width:764px;margin-left:0}table .span11{float:none;width:844px;margin-left:0}table .span12{float:none;width:924px;margin-left:0}table .span13{float:none;width:1004px;margin-left:0}table .span14{float:none;width:1084px;margin-left:0}table .span15{float:none;width:1164px;margin-left:0}table .span16{float:none;width:1244px;margin-left:0}table .span17{float:none;width:1324px;margin-left:0}table .span18{float:none;width:1404px;margin-left:0}table .span19{float:none;width:1484px;margin-left:0}table .span20{float:none;width:1564px;margin-left:0}table .span21{float:none;width:1644px;margin-left:0}table .span22{float:none;width:1724px;margin-left:0}table .span23{float:none;width:1804px;margin-left:0}table .span24{float:none;width:1884px;margin-left:0}[class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("../img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}[class^="icon-"]:last-child,[class*=" icon-"]:last-child{*margin-left:0}.icon-white{background-image:url("../img/glyphicons-halflings-white.png")}.icon-glass{background-position:0 0}.icon-music{background-position:-24px 0}.icon-search{background-position:-48px 0}.icon-envelope{background-position:-72px 0}.icon-heart{background-position:-96px 0}.icon-star{background-position:-120px 0}.icon-star-empty{background-position:-144px 0}.icon-user{background-position:-168px 0}.icon-film{background-position:-192px 0}.icon-th-large{background-position:-216px 0}.icon-th{background-position:-240px 0}.icon-th-list{background-position:-264px 0}.icon-ok{background-position:-288px 0}.icon-remove{background-position:-312px 0}.icon-zoom-in{background-position:-336px 0}.icon-zoom-out{background-position:-360px 0}.icon-off{background-position:-384px 0}.icon-signal{background-position:-408px 0}.icon-cog{background-position:-432px 0}.icon-trash{background-position:-456px 0}.icon-home{background-position:0 -24px}.icon-file{background-position:-24px -24px}.icon-time{background-position:-48px -24px}.icon-road{background-position:-72px -24px}.icon-download-alt{background-position:-96px -24px}.icon-download{background-position:-120px -24px}.icon-upload{background-position:-144px -24px}.icon-inbox{background-position:-168px -24px}.icon-play-circle{background-position:-192px -24px}.icon-repeat{background-position:-216px -24px}.icon-refresh{background-position:-240px -24px}.icon-list-alt{background-position:-264px -24px}.icon-lock{background-position:-287px -24px}.icon-flag{background-position:-312px -24px}.icon-headphones{background-position:-336px -24px}.icon-volume-off{background-position:-360px -24px}.icon-volume-down{background-position:-384px -24px}.icon-volume-up{background-position:-408px -24px}.icon-qrcode{background-position:-432px -24px}.icon-barcode{background-position:-456px -24px}.icon-tag{background-position:0 -48px}.icon-tags{background-position:-25px -48px}.icon-book{background-position:-48px -48px}.icon-bookmark{background-position:-72px -48px}.icon-print{background-position:-96px -48px}.icon-camera{background-position:-120px -48px}.icon-font{background-position:-144px -48px}.icon-bold{background-position:-167px -48px}.icon-italic{background-position:-192px -48px}.icon-text-height{background-position:-216px -48px}.icon-text-width{background-position:-240px -48px}.icon-align-left{background-position:-264px -48px}.icon-align-center{background-position:-288px -48px}.icon-align-right{background-position:-312px -48px}.icon-align-justify{background-position:-336px -48px}.icon-list{background-position:-360px -48px}.icon-indent-left{background-position:-384px -48px}.icon-indent-right{background-position:-408px -48px}.icon-facetime-video{background-position:-432px -48px}.icon-picture{background-position:-456px -48px}.icon-pencil{background-position:0 -72px}.icon-map-marker{background-position:-24px -72px}.icon-adjust{background-position:-48px -72px}.icon-tint{background-position:-72px -72px}.icon-edit{background-position:-96px -72px}.icon-share{background-position:-120px -72px}.icon-check{background-position:-144px -72px}.icon-move{background-position:-168px -72px}.icon-step-backward{background-position:-192px -72px}.icon-fast-backward{background-position:-216px -72px}.icon-backward{background-position:-240px -72px}.icon-play{background-position:-264px -72px}.icon-pause{background-position:-288px -72px}.icon-stop{background-position:-312px -72px}.icon-forward{background-position:-336px -72px}.icon-fast-forward{background-position:-360px -72px}.icon-step-forward{background-position:-384px -72px}.icon-eject{background-position:-408px -72px}.icon-chevron-left{background-position:-432px -72px}.icon-chevron-right{background-position:-456px -72px}.icon-plus-sign{background-position:0 -96px}.icon-minus-sign{background-position:-24px -96px}.icon-remove-sign{background-position:-48px -96px}.icon-ok-sign{background-position:-72px -96px}.icon-question-sign{background-position:-96px -96px}.icon-info-sign{background-position:-120px -96px}.icon-screenshot{background-position:-144px -96px}.icon-remove-circle{background-position:-168px -96px}.icon-ok-circle{background-position:-192px -96px}.icon-ban-circle{background-position:-216px -96px}.icon-arrow-left{background-position:-240px -96px}.icon-arrow-right{background-position:-264px -96px}.icon-arrow-up{background-position:-289px -96px}.icon-arrow-down{background-position:-312px -96px}.icon-share-alt{background-position:-336px -96px}.icon-resize-full{background-position:-360px -96px}.icon-resize-small{background-position:-384px -96px}.icon-plus{background-position:-408px -96px}.icon-minus{background-position:-433px -96px}.icon-asterisk{background-position:-456px -96px}.icon-exclamation-sign{background-position:0 -120px}.icon-gift{background-position:-24px -120px}.icon-leaf{background-position:-48px -120px}.icon-fire{background-position:-72px -120px}.icon-eye-open{background-position:-96px -120px}.icon-eye-close{background-position:-120px -120px}.icon-warning-sign{background-position:-144px -120px}.icon-plane{background-position:-168px -120px}.icon-calendar{background-position:-192px -120px}.icon-random{background-position:-216px -120px}.icon-comment{background-position:-240px -120px}.icon-magnet{background-position:-264px -120px}.icon-chevron-up{background-position:-288px -120px}.icon-chevron-down{background-position:-313px -119px}.icon-retweet{background-position:-336px -120px}.icon-shopping-cart{background-position:-360px -120px}.icon-folder-close{background-position:-384px -120px}.icon-folder-open{background-position:-408px -120px}.icon-resize-vertical{background-position:-432px -119px}.icon-resize-horizontal{background-position:-456px -118px}.icon-hdd{background-position:0 -144px}.icon-bullhorn{background-position:-24px -144px}.icon-bell{background-position:-48px -144px}.icon-certificate{background-position:-72px -144px}.icon-thumbs-up{background-position:-96px -144px}.icon-thumbs-down{background-position:-120px -144px}.icon-hand-right{background-position:-144px -144px}.icon-hand-left{background-position:-168px -144px}.icon-hand-up{background-position:-192px -144px}.icon-hand-down{background-position:-216px -144px}.icon-circle-arrow-right{background-position:-240px -144px}.icon-circle-arrow-left{background-position:-264px -144px}.icon-circle-arrow-up{background-position:-288px -144px}.icon-circle-arrow-down{background-position:-312px -144px}.icon-globe{background-position:-336px -144px}.icon-wrench{background-position:-360px -144px}.icon-tasks{background-position:-384px -144px}.icon-filter{background-position:-408px -144px}.icon-briefcase{background-position:-432px -144px}.icon-fullscreen{background-position:-456px -144px}.dropup,.dropdown{position:relative}.dropdown-toggle{*margin-bottom:-3px}.dropdown-toggle:active,.open .dropdown-toggle{outline:0}.caret{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid #000;border-right:4px solid transparent;border-left:4px solid transparent;content:"";opacity:.3;filter:alpha(opacity=30)}.dropdown .caret{margin-top:8px;margin-left:2px}.dropdown:hover .caret,.open .caret{opacity:1;filter:alpha(opacity=100)}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:4px 0;margin:1px 0 0;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);*border-right-width:2px;*border-bottom-width:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{*width:100%;height:1px;margin:8px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.dropdown-menu a{display:block;padding:3px 15px;clear:both;font-weight:normal;line-height:18px;color:#333;white-space:nowrap}.dropdown-menu li>a:hover,.dropdown-menu .active>a,.dropdown-menu .active>a:hover{color:#fff;text-decoration:none;background-color:#08c}.open{*z-index:1000}.open .dropdown-menu{display:block}.pull-right .dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid #000;content:"\2191"}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}.typeahead{margin-top:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #eee;border:1px solid rgba(0,0,0,0.05);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-large{padding:24px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.well-small{padding:9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.fade{opacity:0;filter:alpha(opacity=0);-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-ms-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1;filter:alpha(opacity=100)}.collapse{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;-moz-transition:height .35s ease;-ms-transition:height .35s ease;-o-transition:height .35s ease;transition:height .35s ease}.collapse.in{height:auto}.close{float:right;font-size:20px;font-weight:bold;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.btn{display:inline-block;*display:inline;padding:4px 10px 4px;margin-bottom:0;*margin-left:.3em;font-size:13px;line-height:18px;*line-height:20px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);vertical-align:middle;cursor:pointer;background-color:#f5f5f5;*background-color:#e6e6e6;background-image:-ms-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(top,#fff,#e6e6e6);background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-repeat:repeat-x;border:1px solid #ccc;*border:0;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff',endColorstr='#e6e6e6',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false);*zoom:1;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn:hover,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover{color:#333;text-decoration:none;background-color:#e6e6e6;*background-color:#d9d9d9;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-ms-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-color:#e6e6e6;background-color:#d9d9d9 \9;background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn.disabled,.btn[disabled]{cursor:default;background-color:#e6e6e6;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:9px 14px;font-size:15px;line-height:normal;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.btn-large [class^="icon-"]{margin-top:1px}.btn-small{padding:5px 9px;font-size:11px;line-height:16px}.btn-small [class^="icon-"]{margin-top:-1px}.btn-mini{padding:2px 6px;font-size:11px;line-height:14px}.btn-primary,.btn-primary:hover,.btn-warning,.btn-warning:hover,.btn-danger,.btn-danger:hover,.btn-success,.btn-success:hover,.btn-info,.btn-info:hover,.btn-inverse,.btn-inverse:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn{border-color:#ccc;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25)}.btn-primary{background-color:#0074cc;*background-color:#05c;background-image:-ms-linear-gradient(top,#08c,#05c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#05c));background-image:-webkit-linear-gradient(top,#08c,#05c);background-image:-o-linear-gradient(top,#08c,#05c);background-image:-moz-linear-gradient(top,#08c,#05c);background-image:linear-gradient(top,#08c,#05c);background-repeat:repeat-x;border-color:#05c #05c #003580;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#0088cc',endColorstr='#0055cc',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{background-color:#05c;*background-color:#004ab3}.btn-primary:active,.btn-primary.active{background-color:#004099 \9}.btn-warning{background-color:#faa732;*background-color:#f89406;background-image:-ms-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(top,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450',endColorstr='#f89406',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{background-color:#f89406;*background-color:#df8505}.btn-warning:active,.btn-warning.active{background-color:#c67605 \9}.btn-danger{background-color:#da4f49;*background-color:#bd362f;background-image:-ms-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(top,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b',endColorstr='#bd362f',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-danger:hover,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{background-color:#bd362f;*background-color:#a9302a}.btn-danger:active,.btn-danger.active{background-color:#942a25 \9}.btn-success{background-color:#5bb75b;*background-color:#51a351;background-image:-ms-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(top,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#62c462',endColorstr='#51a351',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-success:hover,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{background-color:#51a351;*background-color:#499249}.btn-success:active,.btn-success.active{background-color:#408140 \9}.btn-info{background-color:#49afcd;*background-color:#2f96b4;background-image:-ms-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(top,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de',endColorstr='#2f96b4',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-info:hover,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{background-color:#2f96b4;*background-color:#2a85a0}.btn-info:active,.btn-info.active{background-color:#24748c \9}.btn-inverse{background-color:#414141;*background-color:#222;background-image:-ms-linear-gradient(top,#555,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#555),to(#222));background-image:-webkit-linear-gradient(top,#555,#222);background-image:-o-linear-gradient(top,#555,#222);background-image:-moz-linear-gradient(top,#555,#222);background-image:linear-gradient(top,#555,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#555555',endColorstr='#222222',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-inverse:hover,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{background-color:#222;*background-color:#151515}.btn-inverse:active,.btn-inverse.active{background-color:#080808 \9}button.btn,input[type="submit"].btn{*padding-top:2px;*padding-bottom:2px}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type="submit"].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-group{position:relative;*margin-left:.3em;*zoom:1}.btn-group:before,.btn-group:after{display:table;content:""}.btn-group:after{clear:both}.btn-group:first-child{*margin-left:0}.btn-group+.btn-group{margin-left:5px}.btn-toolbar{margin-top:9px;margin-bottom:9px}.btn-toolbar .btn-group{display:inline-block;*display:inline;*zoom:1}.btn-group>.btn{position:relative;float:left;margin-left:-1px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group>.btn:first-child{margin-left:0;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.btn-group>.btn:last-child,.btn-group>.dropdown-toggle{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.btn-group>.btn.large:first-child{margin-left:0;-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.btn-group>.btn.large:last-child,.btn-group>.large.dropdown-toggle{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active{z-index:2}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.dropdown-toggle{*padding-top:4px;padding-right:8px;*padding-bottom:4px;padding-left:8px;-webkit-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn-group>.btn-mini.dropdown-toggle{padding-right:5px;padding-left:5px}.btn-group>.btn-small.dropdown-toggle{*padding-top:4px;*padding-bottom:4px}.btn-group>.btn-large.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn-group.open .btn.dropdown-toggle{background-color:#e6e6e6}.btn-group.open .btn-primary.dropdown-toggle{background-color:#05c}.btn-group.open .btn-warning.dropdown-toggle{background-color:#f89406}.btn-group.open .btn-danger.dropdown-toggle{background-color:#bd362f}.btn-group.open .btn-success.dropdown-toggle{background-color:#51a351}.btn-group.open .btn-info.dropdown-toggle{background-color:#2f96b4}.btn-group.open .btn-inverse.dropdown-toggle{background-color:#222}.btn .caret{margin-top:7px;margin-left:0}.btn:hover .caret,.open.btn-group .caret{opacity:1;filter:alpha(opacity=100)}.btn-mini .caret{margin-top:5px}.btn-small .caret{margin-top:6px}.btn-large .caret{margin-top:6px;border-top-width:5px;border-right-width:5px;border-left-width:5px}.dropup .btn-large .caret{border-top:0;border-bottom:5px solid #000}.btn-primary .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret,.btn-success .caret,.btn-inverse .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:.75;filter:alpha(opacity=75)}.alert{padding:8px 35px 8px 14px;margin-bottom:18px;color:#c09853;text-shadow:0 1px 0 rgba(255,255,255,0.5);background-color:#fcf8e3;border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.alert-heading{color:inherit}.alert .close{position:relative;top:-2px;right:-21px;line-height:18px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-danger,.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-block{padding-top:14px;padding-bottom:14px}.alert-block>p,.alert-block>ul{margin-bottom:0}.alert-block p+p{margin-top:5px}.nav{margin-bottom:18px;margin-left:0;list-style:none}.nav>li>a{display:block}.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>.pull-right{float:right}.nav .nav-header{display:block;padding:3px 15px;font-size:11px;font-weight:bold;line-height:18px;color:#999;text-shadow:0 1px 0 rgba(255,255,255,0.5);text-transform:uppercase}.nav li+.nav-header{margin-top:9px}.nav-list{padding-right:15px;padding-left:15px;margin-bottom:0}.nav-list>li>a,.nav-list .nav-header{margin-right:-15px;margin-left:-15px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.nav-list>li>a{padding:3px 15px}.nav-list>.active>a,.nav-list>.active>a:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.2);background-color:#08c}.nav-list [class^="icon-"]{margin-right:2px}.nav-list .divider{*width:100%;height:1px;margin:8px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.nav-tabs,.nav-pills{*zoom:1}.nav-tabs:before,.nav-pills:before,.nav-tabs:after,.nav-pills:after{display:table;content:""}.nav-tabs:after,.nav-pills:after{clear:both}.nav-tabs>li,.nav-pills>li{float:left}.nav-tabs>li>a,.nav-pills>li>a{padding-right:12px;padding-left:12px;margin-right:2px;line-height:14px}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{margin-bottom:-1px}.nav-tabs>li>a{padding-top:8px;padding-bottom:8px;line-height:18px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>.active>a,.nav-tabs>.active>a:hover{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-pills>li>a{padding-top:8px;padding-bottom:8px;margin-top:2px;margin-bottom:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.nav-pills>.active>a,.nav-pills>.active>a:hover{color:#fff;background-color:#08c}.nav-stacked>li{float:none}.nav-stacked>li>a{margin-right:0}.nav-tabs.nav-stacked{border-bottom:0}.nav-tabs.nav-stacked>li>a{border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.nav-tabs.nav-stacked>li:first-child>a{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs.nav-stacked>li:last-child>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.nav-tabs.nav-stacked>li>a:hover{z-index:2;border-color:#ddd}.nav-pills.nav-stacked>li>a{margin-bottom:3px}.nav-pills.nav-stacked>li:last-child>a{margin-bottom:1px}.nav-tabs .dropdown-menu{-webkit-border-radius:0 0 5px 5px;-moz-border-radius:0 0 5px 5px;border-radius:0 0 5px 5px}.nav-pills .dropdown-menu{-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-tabs .dropdown-toggle .caret,.nav-pills .dropdown-toggle .caret{margin-top:6px;border-top-color:#08c;border-bottom-color:#08c}.nav-tabs .dropdown-toggle:hover .caret,.nav-pills .dropdown-toggle:hover .caret{border-top-color:#005580;border-bottom-color:#005580}.nav-tabs .active .dropdown-toggle .caret,.nav-pills .active .dropdown-toggle .caret{border-top-color:#333;border-bottom-color:#333}.nav>.dropdown.active>a:hover{color:#000;cursor:pointer}.nav-tabs .open .dropdown-toggle,.nav-pills .open .dropdown-toggle,.nav>li.dropdown.open.active>a:hover{color:#fff;background-color:#999;border-color:#999}.nav li.dropdown.open .caret,.nav li.dropdown.open.active .caret,.nav li.dropdown.open a:hover .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:1;filter:alpha(opacity=100)}.tabs-stacked .open>a:hover{border-color:#999}.tabbable{*zoom:1}.tabbable:before,.tabbable:after{display:table;content:""}.tabbable:after{clear:both}.tab-content{overflow:auto}.tabs-below>.nav-tabs,.tabs-right>.nav-tabs,.tabs-left>.nav-tabs{border-bottom:0}.tab-content>.tab-pane,.pill-content>.pill-pane{display:none}.tab-content>.active,.pill-content>.active{display:block}.tabs-below>.nav-tabs{border-top:1px solid #ddd}.tabs-below>.nav-tabs>li{margin-top:-1px;margin-bottom:0}.tabs-below>.nav-tabs>li>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.tabs-below>.nav-tabs>li>a:hover{border-top-color:#ddd;border-bottom-color:transparent}.tabs-below>.nav-tabs>.active>a,.tabs-below>.nav-tabs>.active>a:hover{border-color:transparent #ddd #ddd #ddd}.tabs-left>.nav-tabs>li,.tabs-right>.nav-tabs>li{float:none}.tabs-left>.nav-tabs>li>a,.tabs-right>.nav-tabs>li>a{min-width:74px;margin-right:0;margin-bottom:3px}.tabs-left>.nav-tabs{float:left;margin-right:19px;border-right:1px solid #ddd}.tabs-left>.nav-tabs>li>a{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.tabs-left>.nav-tabs>li>a:hover{border-color:#eee #ddd #eee #eee}.tabs-left>.nav-tabs .active>a,.tabs-left>.nav-tabs .active>a:hover{border-color:#ddd transparent #ddd #ddd;*border-right-color:#fff}.tabs-right>.nav-tabs{float:right;margin-left:19px;border-left:1px solid #ddd}.tabs-right>.nav-tabs>li>a{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.tabs-right>.nav-tabs>li>a:hover{border-color:#eee #eee #eee #ddd}.tabs-right>.nav-tabs .active>a,.tabs-right>.nav-tabs .active>a:hover{border-color:#ddd #ddd #ddd transparent;*border-left-color:#fff}.navbar{*position:relative;*z-index:2;margin-bottom:18px;overflow:visible}.navbar-inner{min-height:40px;padding-right:20px;padding-left:20px;background-color:#2c2c2c;background-image:-moz-linear-gradient(top,#333,#222);background-image:-ms-linear-gradient(top,#333,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#333),to(#222));background-image:-webkit-linear-gradient(top,#333,#222);background-image:-o-linear-gradient(top,#333,#222);background-image:linear-gradient(top,#333,#222);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#333333',endColorstr='#222222',GradientType=0);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1)}.navbar .container{width:auto}.nav-collapse.collapse{height:auto}.navbar{color:#999}.navbar .brand:hover{text-decoration:none}.navbar .brand{display:block;float:left;padding:8px 20px 12px;margin-left:-20px;font-size:20px;font-weight:200;line-height:1;color:#999}.navbar .navbar-text{margin-bottom:0;line-height:40px}.navbar .navbar-link{color:#999}.navbar .navbar-link:hover{color:#fff}.navbar .btn,.navbar .btn-group{margin-top:5px}.navbar .btn-group .btn{margin:0}.navbar-form{margin-bottom:0;*zoom:1}.navbar-form:before,.navbar-form:after{display:table;content:""}.navbar-form:after{clear:both}.navbar-form input,.navbar-form select,.navbar-form .radio,.navbar-form .checkbox{margin-top:5px}.navbar-form input,.navbar-form select{display:inline-block;margin-bottom:0}.navbar-form input[type="image"],.navbar-form input[type="checkbox"],.navbar-form input[type="radio"]{margin-top:3px}.navbar-form .input-append,.navbar-form .input-prepend{margin-top:6px;white-space:nowrap}.navbar-form .input-append input,.navbar-form .input-prepend input{margin-top:0}.navbar-search{position:relative;float:left;margin-top:6px;margin-bottom:0}.navbar-search .search-query{padding:4px 9px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:1;color:#fff;background-color:#626262;border:1px solid #151515;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none}.navbar-search .search-query:-moz-placeholder{color:#ccc}.navbar-search .search-query::-webkit-input-placeholder{color:#ccc}.navbar-search .search-query:focus,.navbar-search .search-query.focused{padding:5px 10px;color:#333;text-shadow:0 1px 0 #fff;background-color:#fff;border:0;outline:0;-webkit-box-shadow:0 0 3px rgba(0,0,0,0.15);-moz-box-shadow:0 0 3px rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.15)}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030;margin-bottom:0}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding-right:0;padding-left:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.navbar-fixed-top{top:0}.navbar-fixed-bottom{bottom:0}.navbar .nav{position:relative;left:0;display:block;float:left;margin:0 10px 0 0}.navbar .nav.pull-right{float:right}.navbar .nav>li{display:block;float:left}.navbar .nav>li>a{float:none;padding:9px 10px 11px;line-height:19px;color:#999;text-decoration:none;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.navbar .btn{display:inline-block;padding:4px 10px 4px;margin:5px 5px 6px;line-height:18px}.navbar .btn-group{padding:5px 5px 6px;margin:0}.navbar .nav>li>a:hover{color:#fff;text-decoration:none;background-color:transparent}.navbar .nav .active>a,.navbar .nav .active>a:hover{color:#fff;text-decoration:none;background-color:#222}.navbar .divider-vertical{width:1px;height:40px;margin:0 9px;overflow:hidden;background-color:#222;border-right:1px solid #333}.navbar .nav.pull-right{margin-right:0;margin-left:10px}.navbar .btn-navbar{display:none;float:right;padding:7px 10px;margin-right:5px;margin-left:5px;background-color:#2c2c2c;*background-color:#222;background-image:-ms-linear-gradient(top,#333,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#333),to(#222));background-image:-webkit-linear-gradient(top,#333,#222);background-image:-o-linear-gradient(top,#333,#222);background-image:linear-gradient(top,#333,#222);background-image:-moz-linear-gradient(top,#333,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#333333',endColorstr='#222222',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075)}.navbar .btn-navbar:hover,.navbar .btn-navbar:active,.navbar .btn-navbar.active,.navbar .btn-navbar.disabled,.navbar .btn-navbar[disabled]{background-color:#222;*background-color:#151515}.navbar .btn-navbar:active,.navbar .btn-navbar.active{background-color:#080808 \9}.navbar .btn-navbar .icon-bar{display:block;width:18px;height:2px;background-color:#f5f5f5;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.25);-moz-box-shadow:0 1px 0 rgba(0,0,0,0.25);box-shadow:0 1px 0 rgba(0,0,0,0.25)}.btn-navbar .icon-bar+.icon-bar{margin-top:3px}.navbar .dropdown-menu:before{position:absolute;top:-7px;left:9px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.navbar .dropdown-menu:after{position:absolute;top:-6px;left:10px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent;content:''}.navbar-fixed-bottom .dropdown-menu:before{top:auto;bottom:-7px;border-top:7px solid #ccc;border-bottom:0;border-top-color:rgba(0,0,0,0.2)}.navbar-fixed-bottom .dropdown-menu:after{top:auto;bottom:-6px;border-top:6px solid #fff;border-bottom:0}.navbar .nav li.dropdown .dropdown-toggle .caret,.navbar .nav li.dropdown.open .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar .nav li.dropdown.active .caret{opacity:1;filter:alpha(opacity=100)}.navbar .nav li.dropdown.open>.dropdown-toggle,.navbar .nav li.dropdown.active>.dropdown-toggle,.navbar .nav li.dropdown.open.active>.dropdown-toggle{background-color:transparent}.navbar .nav li.dropdown.active>.dropdown-toggle:hover{color:#fff}.navbar .pull-right .dropdown-menu,.navbar .dropdown-menu.pull-right{right:0;left:auto}.navbar .pull-right .dropdown-menu:before,.navbar .dropdown-menu.pull-right:before{right:12px;left:auto}.navbar .pull-right .dropdown-menu:after,.navbar .dropdown-menu.pull-right:after{right:13px;left:auto}.breadcrumb{padding:7px 14px;margin:0 0 18px;list-style:none;background-color:#fbfbfb;background-image:-moz-linear-gradient(top,#fff,#f5f5f5);background-image:-ms-linear-gradient(top,#fff,#f5f5f5);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#f5f5f5));background-image:-webkit-linear-gradient(top,#fff,#f5f5f5);background-image:-o-linear-gradient(top,#fff,#f5f5f5);background-image:linear-gradient(top,#fff,#f5f5f5);background-repeat:repeat-x;border:1px solid #ddd;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff',endColorstr='#f5f5f5',GradientType=0);-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.breadcrumb li{display:inline-block;*display:inline;text-shadow:0 1px 0 #fff;*zoom:1}.breadcrumb .divider{padding:0 5px;color:#999}.breadcrumb .active a{color:#333}.pagination{height:36px;margin:18px 0}.pagination ul{display:inline-block;*display:inline;margin-bottom:0;margin-left:0;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;*zoom:1;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.pagination li{display:inline}.pagination a{float:left;padding:0 14px;line-height:34px;text-decoration:none;border:1px solid #ddd;border-left-width:0}.pagination a:hover,.pagination .active a{background-color:#f5f5f5}.pagination .active a{color:#999;cursor:default}.pagination .disabled span,.pagination .disabled a,.pagination .disabled a:hover{color:#999;cursor:default;background-color:transparent}.pagination li:first-child a{border-left-width:1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.pagination li:last-child a{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.pagination-centered{text-align:center}.pagination-right{text-align:right}.pager{margin-bottom:18px;margin-left:0;text-align:center;list-style:none;*zoom:1}.pager:before,.pager:after{display:table;content:""}.pager:after{clear:both}.pager li{display:inline}.pager a{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.pager a:hover{text-decoration:none;background-color:#f5f5f5}.pager .next a{float:right}.pager .previous a{float:left}.pager .disabled a,.pager .disabled a:hover{color:#999;cursor:default;background-color:#fff}.modal-open .dropdown-menu{z-index:2050}.modal-open .dropdown.open{*z-index:2050}.modal-open .popover{z-index:2060}.modal-open .tooltip{z-index:2070}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{opacity:.8;filter:alpha(opacity=80)}.modal{position:fixed;top:50%;left:50%;z-index:1050;width:560px;margin:-250px 0 0 -280px;overflow:auto;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal.fade{top:-25%;-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-ms-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out}.modal.fade.in{top:50%}.modal-header{padding:9px 15px;border-bottom:1px solid #eee}.modal-header .close{margin-top:2px}.modal-body{max-height:400px;padding:15px;overflow-y:auto}.modal-form{margin-bottom:0}.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;*zoom:1;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.modal-footer:before,.modal-footer:after{display:table;content:""}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.tooltip{position:absolute;z-index:1020;display:block;padding:5px;font-size:11px;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.8;filter:alpha(opacity=80)}.tooltip.top{margin-top:-2px}.tooltip.right{margin-left:2px}.tooltip.bottom{margin-top:2px}.tooltip.left{margin-left:-2px}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top:5px solid #000;border-right:5px solid transparent;border-left:5px solid transparent}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-right:5px solid transparent;border-bottom:5px solid #000;border-left:5px solid transparent}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-right:5px solid #000;border-bottom:5px solid transparent}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;padding:5px}.popover.top{margin-top:-5px}.popover.right{margin-left:5px}.popover.bottom{margin-top:5px}.popover.left{margin-left:-5px}.popover.top .arrow{bottom:0;left:50%;margin-left:-5px;border-top:5px solid #000;border-right:5px solid transparent;border-left:5px solid transparent}.popover.right .arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-right:5px solid #000;border-bottom:5px solid transparent}.popover.bottom .arrow{top:0;left:50%;margin-left:-5px;border-right:5px solid transparent;border-bottom:5px solid #000;border-left:5px solid transparent}.popover.left .arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.popover .arrow{position:absolute;width:0;height:0}.popover-inner{width:280px;padding:3px;overflow:hidden;background:#000;background:rgba(0,0,0,0.8);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3)}.popover-title{padding:9px 15px;line-height:1;background-color:#f5f5f5;border-bottom:1px solid #eee;-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0}.popover-content{padding:14px;background-color:#fff;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.popover-content p,.popover-content ul,.popover-content ol{margin-bottom:0}.thumbnails{margin-left:-20px;list-style:none;*zoom:1}.thumbnails:before,.thumbnails:after{display:table;content:""}.thumbnails:after{clear:both}.row-fluid .thumbnails{margin-left:0}.thumbnails>li{float:left;margin-bottom:18px;margin-left:20px}.thumbnail{display:block;padding:4px;line-height:1;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:0 1px 1px rgba(0,0,0,0.075);box-shadow:0 1px 1px rgba(0,0,0,0.075)}a.thumbnail:hover{border-color:#08c;-webkit-box-shadow:0 1px 4px rgba(0,105,214,0.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,0.25);box-shadow:0 1px 4px rgba(0,105,214,0.25)}.thumbnail>img{display:block;max-width:100%;margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px}.label,.badge{font-size:10.998px;font-weight:bold;line-height:14px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);white-space:nowrap;vertical-align:baseline;background-color:#999}.label{padding:1px 4px 2px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.badge{padding:1px 9px 2px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px}a.label:hover,a.badge:hover{color:#fff;text-decoration:none;cursor:pointer}.label-important,.badge-important{background-color:#b94a48}.label-important[href],.badge-important[href]{background-color:#953b39}.label-warning,.badge-warning{background-color:#f89406}.label-warning[href],.badge-warning[href]{background-color:#c67605}.label-success,.badge-success{background-color:#468847}.label-success[href],.badge-success[href]{background-color:#356635}.label-info,.badge-info{background-color:#3a87ad}.label-info[href],.badge-info[href]{background-color:#2d6987}.label-inverse,.badge-inverse{background-color:#333}.label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-ms-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:18px;margin-bottom:18px;overflow:hidden;background-color:#f7f7f7;background-image:-moz-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-ms-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f5f5f5),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-o-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:linear-gradient(top,#f5f5f5,#f9f9f9);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#f5f5f5',endColorstr='#f9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress .bar{width:0;height:18px;font-size:12px;color:#fff;text-align:center;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top,#149bdf,#0480be);background-image:-webkit-gradient(linear,0 0,0 100%,from(#149bdf),to(#0480be));background-image:-webkit-linear-gradient(top,#149bdf,#0480be);background-image:-o-linear-gradient(top,#149bdf,#0480be);background-image:linear-gradient(top,#149bdf,#0480be);background-image:-ms-linear-gradient(top,#149bdf,#0480be);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#149bdf',endColorstr='#0480be',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-transition:width .6s ease;-moz-transition:width .6s ease;-ms-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress-striped .bar{background-color:#149bdf;background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px}.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-danger .bar{background-color:#dd514c;background-image:-moz-linear-gradient(top,#ee5f5b,#c43c35);background-image:-ms-linear-gradient(top,#ee5f5b,#c43c35);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#c43c35));background-image:-webkit-linear-gradient(top,#ee5f5b,#c43c35);background-image:-o-linear-gradient(top,#ee5f5b,#c43c35);background-image:linear-gradient(top,#ee5f5b,#c43c35);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b',endColorstr='#c43c35',GradientType=0)}.progress-danger.progress-striped .bar{background-color:#ee5f5b;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-success .bar{background-color:#5eb95e;background-image:-moz-linear-gradient(top,#62c462,#57a957);background-image:-ms-linear-gradient(top,#62c462,#57a957);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#57a957));background-image:-webkit-linear-gradient(top,#62c462,#57a957);background-image:-o-linear-gradient(top,#62c462,#57a957);background-image:linear-gradient(top,#62c462,#57a957);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#62c462',endColorstr='#57a957',GradientType=0)}.progress-success.progress-striped .bar{background-color:#62c462;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-info .bar{background-color:#4bb1cf;background-image:-moz-linear-gradient(top,#5bc0de,#339bb9);background-image:-ms-linear-gradient(top,#5bc0de,#339bb9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#339bb9));background-image:-webkit-linear-gradient(top,#5bc0de,#339bb9);background-image:-o-linear-gradient(top,#5bc0de,#339bb9);background-image:linear-gradient(top,#5bc0de,#339bb9);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de',endColorstr='#339bb9',GradientType=0)}.progress-info.progress-striped .bar{background-color:#5bc0de;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-warning .bar{background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-ms-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(top,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450',endColorstr='#f89406',GradientType=0)}.progress-warning.progress-striped .bar{background-color:#fbb450;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.accordion{margin-bottom:18px}.accordion-group{margin-bottom:2px;border:1px solid #e5e5e5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.accordion-heading{border-bottom:0}.accordion-heading .accordion-toggle{display:block;padding:8px 15px}.accordion-toggle{cursor:pointer}.accordion-inner{padding:9px 15px;border-top:1px solid #e5e5e5}.carousel{position:relative;margin-bottom:18px;line-height:1}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel .item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;-moz-transition:.6s ease-in-out left;-ms-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel .item>img{display:block;line-height:1}.carousel .active,.carousel .next,.carousel .prev{display:block}.carousel .active{left:0}.carousel .next,.carousel .prev{position:absolute;top:0;width:100%}.carousel .next{left:100%}.carousel .prev{left:-100%}.carousel .next.left,.carousel .prev.right{left:0}.carousel .active.left{left:-100%}.carousel .active.right{left:100%}.carousel-control{position:absolute;top:40%;left:15px;width:40px;height:40px;margin-top:-20px;font-size:60px;font-weight:100;line-height:30px;color:#fff;text-align:center;background:#222;border:3px solid #fff;-webkit-border-radius:23px;-moz-border-radius:23px;border-radius:23px;opacity:.5;filter:alpha(opacity=50)}.carousel-control.right{right:15px;left:auto}.carousel-control:hover{color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-caption{position:absolute;right:0;bottom:0;left:0;padding:10px 15px 5px;background:#333;background:rgba(0,0,0,0.75)}.carousel-caption h4,.carousel-caption p{color:#fff}.hero-unit{padding:60px;margin-bottom:30px;background-color:#eee;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;letter-spacing:-1px;color:inherit}.hero-unit p{font-size:18px;font-weight:200;line-height:27px;color:inherit}.pull-right{float:right}.pull-left{float:left}.hide{display:none}.show{display:block}.invisible{visibility:hidden} 10 | -------------------------------------------------------------------------------- /css/godoc.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | /* font-family: Helvetica, Arial, sans-serif; */ 4 | font-size: 16px; 5 | } 6 | pre, 7 | code { 8 | font-family: Menlo, monospace; 9 | font-size: 14px; 10 | } 11 | pre { 12 | line-height: 18px; 13 | } 14 | pre .comment { 15 | color: #375EAB; 16 | } 17 | pre .highlight, 18 | pre .highlight-comment, 19 | pre .selection-highlight, 20 | pre .selection-highlight-comment { 21 | background: #FFFF00; 22 | } 23 | pre .selection, 24 | pre .selection-comment { 25 | background: #FF9632; 26 | } 27 | pre .ln { 28 | color: #999; 29 | } 30 | body { 31 | color: #222; 32 | } 33 | a, 34 | .exampleHeading .text { 35 | color: #375EAB; 36 | text-decoration: none; 37 | } 38 | a:hover, 39 | .exampleHeading .text:hover { 40 | text-decoration: underline; 41 | } 42 | p, 43 | pre, 44 | ul, 45 | ol { 46 | margin: 20px; 47 | } 48 | pre { 49 | background: #e9e9e9; 50 | padding: 10px; 51 | 52 | -webkit-border-radius: 5px; 53 | -moz-border-radius: 5px; 54 | border-radius: 5px; 55 | } 56 | 57 | h1, 58 | h2, 59 | h3, 60 | h4, 61 | .rootHeading { 62 | margin: 20px 0; 63 | padding: 0; 64 | color: #375EAB; 65 | font-weight: bold; 66 | } 67 | h1 { 68 | font-size: 24px; 69 | } 70 | h2 { 71 | font-size: 20px; 72 | background: #E0EBF5; 73 | padding: 2px 5px; 74 | } 75 | h3 { 76 | font-size: 20px; 77 | } 78 | h3, 79 | h4 { 80 | margin: 20px 5px; 81 | } 82 | h4 { 83 | font-size: 16px; 84 | } 85 | .rootHeading { 86 | font-size: 20px; 87 | margin: 0; 88 | } 89 | 90 | dl { 91 | margin: 20px; 92 | } 93 | dd { 94 | margin: 2px 20px; 95 | } 96 | dl, 97 | dd { 98 | font-size: 14px; 99 | } 100 | div#nav table td { 101 | vertical-align: top; 102 | } 103 | 104 | table.dir th { 105 | text-align: left; 106 | } 107 | table.dir td { 108 | word-wrap: break-word; 109 | vertical-align: top; 110 | } 111 | 112 | .alert { 113 | color: #AA0000; 114 | } 115 | 116 | div#heading { 117 | float: left; 118 | margin: 0 0 10px 0; 119 | padding: 21px 0; 120 | font-size: 20px; 121 | font-weight: normal; 122 | } 123 | div#heading a { 124 | color: #222; 125 | text-decoration: none; 126 | } 127 | 128 | div#topbar { 129 | background: #E0EBF5; 130 | height: 64px; 131 | } 132 | 133 | body { 134 | text-align: center; 135 | } 136 | div#page, 137 | div#topbar > .container { 138 | clear: both; 139 | text-align: left; 140 | margin-left: auto; 141 | margin-right: auto; 142 | padding: 0 20px; 143 | } 144 | div#page.wide, 145 | div#topbar > .wide { 146 | width: auto; 147 | } 148 | div#plusone { 149 | float: right; 150 | } 151 | 152 | div#footer { 153 | color: #666; 154 | font-size: 14px; 155 | margin: 40px 0; 156 | } 157 | 158 | div#menu > a, 159 | div#menu > input, 160 | div#learn .buttons a, 161 | div#blog .read a { 162 | padding: 10px; 163 | 164 | text-decoration: none; 165 | font-size: 16px; 166 | 167 | -webkit-border-radius: 5px; 168 | -moz-border-radius: 5px; 169 | border-radius: 5px; 170 | } 171 | div#menu > a, 172 | div#menu > input { 173 | border: 1px solid #375EAB; 174 | } 175 | div#menu > a { 176 | color: white; 177 | background: #375EAB; 178 | } 179 | a#start, 180 | div#learn .buttons a, 181 | div#blog .read a { 182 | color: #222; 183 | border: 1px solid #375EAB; 184 | background: #E0EBF5; 185 | } 186 | 187 | div#menu { 188 | float: right; 189 | min-width: 590px; 190 | padding: 10px 0; 191 | text-align: right; 192 | } 193 | div#menu > a { 194 | margin-right: 5px; 195 | margin-bottom: 10px; 196 | 197 | padding: 10px; 198 | } 199 | div#menu > input { 200 | position: relative; 201 | top: 1px; 202 | width: 60px; 203 | background: white; 204 | color: #222; 205 | } 206 | div#menu > input.inactive { 207 | color: #999; 208 | } 209 | 210 | div.left { 211 | float: left; 212 | } 213 | div.right { 214 | float: right; 215 | } 216 | div.left, 217 | div.right { 218 | width: 415px; 219 | } 220 | 221 | div#learn, 222 | div#about { 223 | padding-top: 20px; 224 | } 225 | div#learn h2, 226 | div#about { 227 | margin: 0; 228 | } 229 | div#about { 230 | font-size: 20px; 231 | } 232 | 233 | div#about { 234 | height: 96px; 235 | } 236 | div#gopher { 237 | background: url(/doc/gopher/frontpage.png) no-repeat; 238 | background-position: center top; 239 | height: 155px; 240 | } 241 | a#start { 242 | display: block; 243 | padding: 10px; 244 | 245 | text-align: center; 246 | text-decoration: none; 247 | 248 | -webkit-border-radius: 5px; 249 | -moz-border-radius: 5px; 250 | border-radius: 5px; 251 | } 252 | a#start .big { 253 | font-weight: bold; 254 | font-size: 20px; 255 | } 256 | a#start .desc { 257 | font-size: 14px; 258 | font-weight: normal; 259 | margin-top: 5px; 260 | } 261 | 262 | div#learn .icon { 263 | float: right; 264 | cursor: pointer; 265 | } 266 | div#learn pre, 267 | div#learn textarea { 268 | padding: 0; 269 | margin: 0; 270 | font-family: Menlo, monospace; 271 | font-size: 14px; 272 | } 273 | div#learn .input { 274 | padding: 10px; 275 | margin-top: 10px; 276 | height: 150px; 277 | 278 | -webkit-border-top-left-radius: 5px; 279 | -webkit-border-top-right-radius: 5px; 280 | -moz-border-radius-topleft: 5px; 281 | -moz-border-radius-topright: 5px; 282 | border-top-left-radius: 5px; 283 | border-top-right-radius: 5px; 284 | } 285 | div#learn .input textarea { 286 | width: 100%; 287 | height: 100%; 288 | border: none; 289 | outline: none; 290 | resize: none; 291 | } 292 | div#learn .output { 293 | border-top: none !important; 294 | 295 | padding: 10px; 296 | height: 59px; 297 | overflow: auto; 298 | 299 | -webkit-border-bottom-right-radius: 5px; 300 | -webkit-border-bottom-left-radius: 5px; 301 | -moz-border-radius-bottomright: 5px; 302 | -moz-border-radius-bottomleft: 5px; 303 | border-bottom-right-radius: 5px; 304 | border-bottom-left-radius: 5px; 305 | } 306 | div#learn .output pre { 307 | padding: 0; 308 | 309 | -webkit-border-radius: 0; 310 | -moz-border-radius: 0; 311 | border-radius: 0; 312 | } 313 | div#learn .input, 314 | div#learn .input textarea, 315 | div#learn .output, 316 | div#learn .output pre { 317 | background: #FFFFD8; 318 | } 319 | div#learn .input, 320 | div#learn .output { 321 | border: 1px solid #375EAB; 322 | } 323 | div#learn .buttons { 324 | float: right; 325 | padding: 20px 0 10px 0; 326 | text-align: right; 327 | } 328 | div#learn .buttons a { 329 | height: 16px; 330 | margin-left: 5px; 331 | padding: 10px; 332 | } 333 | div#learn .toys { 334 | margin-top: 8px; 335 | } 336 | div#learn .toys select { 337 | border: 1px solid #375EAB; 338 | margin: 0; 339 | } 340 | 341 | div#blog, 342 | div#video { 343 | margin-top: 40px; 344 | } 345 | div#blog > a, 346 | div#blog > div, 347 | div#blog > h2, 348 | div#video > a, 349 | div#video > div, 350 | div#video > h2 { 351 | margin-bottom: 10px; 352 | } 353 | div#blog .title, 354 | div#video .title { 355 | display: block; 356 | font-size: 20px; 357 | } 358 | div#blog .when { 359 | color: #666; 360 | font-size: 14px; 361 | } 362 | div#blog .read { 363 | text-align: right; 364 | } 365 | 366 | .toggleButton { cursor: pointer; } 367 | .toggle .collapsed { display: block; } 368 | .toggle .expanded { display: none; } 369 | .toggleVisible .collapsed { display: none; } 370 | .toggleVisible .expanded { display: block; } 371 | 372 | table.codetable { margin-left: auto; margin-right: auto; border-style: none; } 373 | hr { border-style: none; border-top: 1px solid black; } 374 | 375 | img.gopher { 376 | float: right; 377 | margin-left: 10px; 378 | margin-bottom: 10px; 379 | } 380 | .pkgGopher { 381 | text-align: right; 382 | } 383 | .pkgGopher .gopher { 384 | float: none; 385 | position: relative; 386 | top: -40px; 387 | margin-bottom: -120px; 388 | } 389 | h2 { clear: right; } 390 | -------------------------------------------------------------------------------- /css/manual.css: -------------------------------------------------------------------------------- 1 | /* Custom Revel manual styles. */ 2 | 3 | h2 { 4 | margin-top: 20px; 5 | margin-bottom: 15px; 6 | border-bottom: 1px solid #EEE; 7 | } 8 | 9 | h3 { 10 | margin-top: 15px; 11 | margin-bottom: 5px; 12 | } 13 | 14 | h4 { 15 | margin-top: 10px; 16 | margin-bottom: 2px; 17 | } 18 | 19 | .config-overview table { 20 | width: 100%; 21 | } 22 | 23 | .config-overview table td { 24 | text-align: center; 25 | } -------------------------------------------------------------------------------- /css/prettify.css: -------------------------------------------------------------------------------- 1 | .com { color: #93a1a1; } 2 | .lit { color: #195f91; } 3 | .pun, .opn, .clo { color: #93a1a1; } 4 | .fun { color: #dc322f; } 5 | .str, .atv { color: #D14; } 6 | .kwd, .linenums .tag { color: #1e347b; } 7 | .typ, .atn, .dec, .var { color: teal; } 8 | .pln { color: #48484c; } 9 | 10 | .prettyprint { 11 | padding: 8px; 12 | background-color: #f7f7f9; 13 | border: 1px solid #e1e1e8; 14 | } 15 | .prettyprint.linenums { 16 | -webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; 17 | -moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; 18 | box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; 19 | } 20 | 21 | /* Specify class=linenums on a pre to get line numbering */ 22 | ol.linenums { 23 | margin: 0 0 0 33px; /* IE indents via margin-left */ 24 | } 25 | ol.linenums li { 26 | padding-left: 12px; 27 | color: #bebec5; 28 | line-height: 18px; 29 | text-shadow: 0 1px 0 #fff; 30 | } 31 | /*.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}*/ 32 | -------------------------------------------------------------------------------- /css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 0 0 40px 0; 3 | background-color: #fefefe; 4 | } 5 | 6 | .hero-unit { 7 | background-color: #222; 8 | margin-top: 0px; 9 | min-width: 940px; 10 | color:#ccc; 11 | padding-top:0px; 12 | border-bottom:1px solid #375EAB; 13 | 14 | -webkit-border-radius: 0px; 15 | -moz-border-radius: 0px; 16 | border-radius: 0px; 17 | } 18 | 19 | .hero-img { 20 | float:left; 21 | } 22 | 23 | .hero-text { 24 | margin-left:200px; 25 | padding-top:200px; 26 | padding-bottom:150px; 27 | } 28 | 29 | #header { 30 | position: absolute; 31 | width: 100%; 32 | min-width: 940px; 33 | top: 0; 34 | height: 60px; 35 | border-bottom: 1px solid #322; 36 | opacity:0.5; 37 | -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 4px; 38 | -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 4px; 39 | box-shadow: rgba(0, 0, 0, 0.2) 0 2px 4px; 40 | } 41 | 42 | #header #wrapper { 43 | width: 940px; 44 | margin: 0 auto; 45 | position: relative; 46 | } 47 | 48 | #header #nav { 49 | width: 900px; 50 | height: 65px; 51 | margin: 0 auto; 52 | text-align: center; 53 | } 54 | 55 | #header #nav li { 56 | margin: 0 40px; 57 | font-size:28px; 58 | line-height: 26px; 59 | display: inline; 60 | } 61 | 62 | #header #nav li.active a { 63 | font-weight:bold; 64 | color:#eee !important; 65 | } 66 | 67 | a { 68 | color: #0088cc; 69 | text-decoration: none; 70 | } 71 | 72 | a:hover { 73 | color: #005580; 74 | text-decoration: underline; 75 | } 76 | 77 | .container { 78 | padding-left: 5px; 79 | padding-right: 5px; 80 | } 81 | 82 | .navbar { 83 | min-width: 1062px; 84 | } 85 | 86 | .navbar .container { 87 | width: 940px; 88 | } 89 | 90 | .leftnav { 91 | border-right: 1px solid #eee; 92 | padding-top: 15px; 93 | } 94 | 95 | .brand { 96 | padding: 5px 20px 7px !important; 97 | } 98 | 99 | .navbar .nav > li > a { 100 | padding-top: 29px !important; 101 | padding-bottom: 5px !important; 102 | } 103 | 104 | .navbar-inner { 105 | min-height: 0 !important; 106 | height: 55px !important; 107 | background: #FFF; 108 | } 109 | 110 | .nav-list { 111 | padding-left: 10px; 112 | padding-right: 5px; 113 | } 114 | 115 | .nav-list > li > a, .nav-list .nav-header { 116 | margin-right: -5px; 117 | } 118 | 119 | .nav-list > .active > a, .nav-list > .active > a:hover { 120 | background-color: #999 !important; 121 | } 122 | 123 | .navbar .nav .active > a, .navbar .nav .active > a:hover { 124 | color: #fff !important; 125 | background-color: #999 !important; 126 | } 127 | 128 | .navbar .nav li { 129 | line-height: 20px; 130 | } 131 | 132 | .navbar .nav li a { 133 | font-size: 16px; 134 | } 135 | 136 | p, li, h4, h5, h6, dt, dd, address { 137 | line-height: 22px; 138 | } 139 | 140 | h1, h2, h3, h4, h5, h6 { 141 | margin: 14px 0 8px; 142 | } 143 | 144 | li { 145 | margin: 2px; 146 | } 147 | 148 | /* Prefer horizontal scroll to wrapping code */ 149 | pre { 150 | white-space:pre; 151 | word-wrap:normal; 152 | word-break:normal; 153 | overflow-x:auto; 154 | } 155 | 156 | pre.prettyprint { 157 | -webkit-border-radius: 4px; 158 | -moz-border-radius: 4px; 159 | border-radius: 4px; 160 | } 161 | 162 | code { 163 | color: #a14; 164 | background: 0; 165 | border: 0; 166 | } 167 | 168 | a code { 169 | color: #08C; 170 | } 171 | 172 | ul ul, ul ol, ol ol, ol ul, ul { 173 | margin-bottom: 1em; 174 | } 175 | 176 | .improve-page { 177 | float: right; 178 | margin: 0 5px; 179 | position: relative; 180 | } 181 | -------------------------------------------------------------------------------- /errors.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Handling Errors 4 | --- 5 | 6 | Almost all operations with `database/sql` types return an error as the last 7 | value. You should always check these errors, never ignore them. 8 | 9 | There are a few places where error behavior is special-case, or there's 10 | something additional you might need to know. 11 | 12 | Errors From Iterating Resultsets 13 | ================================ 14 | 15 | Consider the following code: 16 | 17 |
 18 | for rows.Next() {
 19 | 	// ...
 20 | }
 21 | if err = rows.Err(); err != nil {
 22 | 	// handle the error here
 23 | }
 24 | 
25 | 26 | The error from `rows.Err()` could be the result of a variety of errors in the 27 | `rows.Next()` loop. The loop 28 | might exit for some reason other than finishing the loop normally, so you always 29 | need to check whether the loop terminated normally or not. An abnormal 30 | termination automatically calls `rows.Close()`, although it's harmless to call it 31 | multiple times. 32 | 33 | Errors From Closing Resultsets 34 | ============================== 35 | 36 | You should always explicitly close a `sql.Rows` if you exit the loop 37 | prematurely, as previously mentioned. It's auto-closed if the loop exits 38 | normally or through an error, but you might mistakenly do this: 39 | 40 |
 41 | for rows.Next() {
 42 | 	// ...
 43 | 	break; // whoops, rows is not closed! memory leak...
 44 | }
 45 | // do the usual "if err = rows.Err()" [omitted here]...
 46 | // it's always safe to [re?]close here:
 47 | if err = rows.Close(); err != nil {
 48 | 	// but what should we do if there's an error?
 49 | 	log.Println(err)
 50 | }
 51 | 
52 | 53 | The error returned by `rows.Close()` is the only exception to the general rule 54 | that it's best to capture and check for errors in all database operations. If 55 | `rows.Close()` returns an error, it's unclear what you should do. 56 | Logging the error message or panicing might be the only sensible thing, 57 | and if that's not sensible, then perhaps you should just ignore the error. 58 | 59 | Errors From QueryRow() 60 | ====================== 61 | 62 | Consider the following code to fetch a single row: 63 | 64 |
 65 | var name string
 66 | err = db.QueryRow("select name from users where id = ?", 1).Scan(&name)
 67 | if err != nil {
 68 | 	log.Fatal(err)
 69 | }
 70 | fmt.Println(name)
 71 | 
72 | 73 | What if there was no user with `id = 1`? Then there would be no row in the 74 | result, and `.Scan()` would not scan a value into `name`. What happens then? 75 | 76 | Go defines a special error constant, called `sql.ErrNoRows`, which is returned 77 | from `QueryRow()` when the result is empty. This needs to be handled as a 78 | special case in most circumstances. An empty result is often not considered an 79 | error by application code, and if you don't check whether an error is this 80 | special constant, you'll cause application-code errors you didn't expect. 81 | 82 | Errors from the query are deferred until `Scan()` is called, and then are 83 | returned from that. The above code is better written like this instead: 84 | 85 |
 86 | var name string
 87 | err = db.QueryRow("select name from users where id = ?", 1).Scan(&name)
 88 | if err != nil {
 89 | 	if err == sql.ErrNoRows {
 90 | 		// there were no rows, but otherwise no error occurred
 91 | 	} else {
 92 | 		log.Fatal(err)
 93 | 	}
 94 | }
 95 | fmt.Println(name)
 96 | 
97 | 98 | One might ask why an empty result set is considered an error. There's nothing 99 | erroneous about an empty set. The reason is that the `QueryRow()` method needs 100 | to use this special-case in order to let the caller distinguish whether 101 | `QueryRow()` in fact found a row; without it, `Scan()` wouldn't do anything and 102 | you might not realize that your variable didn't get any value from the database 103 | after all. 104 | 105 | You should only run into this error when you're using `QueryRow()`. If you 106 | encounter this error elsewhere, you're doing something wrong. 107 | 108 | Identifying Specific Database Errors 109 | ==================================== 110 | 111 | It can be tempting to write code like the following: 112 | 113 |
114 | rows, err := db.Query("SELECT someval FROM sometable")
115 | // err contains:
116 | // ERROR 1045 (28000): Access denied for user 'foo'@'::1' (using password: NO)
117 | if strings.Contains(err.Error(), "Access denied") {
118 | 	// Handle the permission-denied error
119 | }
120 | 
121 | 122 | This is not the best way to do it, though. For example, the string value might 123 | vary depending on what language the server uses to send error messages. It's 124 | much better to compare error numbers to identify what a specific error is. 125 | 126 | The mechanism to do this varies between drivers, however, because this isn't 127 | part of `database/sql` itself. In the MySQL driver that this tutorial focuses 128 | on, you could write the following code: 129 | 130 |
131 | if driverErr, ok := err.(*mysql.MySQLError); ok { // Now the error number is accessible directly
132 | 	if driverErr.Number == 1045 {
133 | 		// Handle the permission-denied error
134 | 	}
135 | }
136 | 
137 | 138 | Again, the `MySQLError` type here is provided by this specific driver, and the 139 | `.Number` field may differ between drivers. The value of the number, however, 140 | is taken from MySQL's error message, and is therefore database specific, not 141 | driver specific. 142 | 143 | This code is still ugly. Comparing to 1045, a magic number, is a code smell. 144 | Some drivers (though not the MySQL one, for reasons that are off-topic here) 145 | provide a list of error identifiers. The Postgres `pq` driver does, for example, in 146 | [error.go](https://github.com/lib/pq/blob/master/error.go). And there's an 147 | external package of [MySQL error numbers maintained by 148 | VividCortex](https://github.com/VividCortex/mysqlerr). Using such a list, the 149 | above code is better written thus: 150 | 151 |
152 | if driverErr, ok := err.(*mysql.MySQLError); ok {
153 | 	if driverErr.Number == mysqlerr.ER_ACCESS_DENIED_ERROR {
154 | 		// Handle the permission-denied error
155 | 	}
156 | }
157 | 
158 | 159 | Handling Connection Errors 160 | ========================== 161 | 162 | What if your connection to the database is dropped, killed, or has an error? 163 | 164 | You don't need to implement any logic to retry failed statements when this 165 | happens. As part of the [connection pooling](connection-pool.html) in 166 | `database/sql`, handling failed connections is built-in. If you execute a query 167 | or other statement and the underlying connection has a failure, Go will reopen a 168 | new connection (or just get another from the connection pool) and retry, up to 169 | 10 times. 170 | 171 | There can be some unintended consequences, however. Some types of errors may be 172 | retried when other error conditions happen. This might also be driver-specific. 173 | One example that has occurred with the MySQL driver is that using `KILL` to 174 | cancel an undesired statement (such as a long-running query) results in the 175 | statement being retried up to 10 times. 176 | 177 | **Previous: [Using Prepared Statements](prepared.html)** 178 | **Next: [Working with NULLs](nulls.html)** 179 | -------------------------------------------------------------------------------- /importing.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Importing a Database Driver 4 | --- 5 | 6 | To use `database/sql` you'll need the package itself, as well as a driver for 7 | the specific database you want to use. 8 | 9 | You generally shouldn't use driver packages directly, although some drivers 10 | encourage you to do so. (In our opinion, it's usually a bad idea.) Instead, your 11 | code should only refer to types defined in `database/sql`, if possible. This 12 | helps avoid making your code dependent on the driver, so that you can change the 13 | underlying driver (and thus the database you're accessing) with minimal code 14 | changes. It also forces you to use the Go idioms instead of ad-hoc idioms that a 15 | particular driver author may have provided. 16 | 17 | In this documentation, we'll use the excellent [MySQL 18 | drivers](https://github.com/go-sql-driver/mysql) from @julienschmidt and @arnehormann 19 | for examples. 20 | 21 | Add the following to the top of your Go source file: 22 | 23 |
24 | import (
25 | 	"database/sql"
26 | 	_ "github.com/go-sql-driver/mysql"
27 | )
28 | 
29 | 30 | Notice that we're loading the driver anonymously, aliasing its package qualifier 31 | to `_` so none of its exported names are visible to our code. Under the hood, 32 | the driver registers itself as being available to the `database/sql` package, 33 | but in general nothing else happens with the exception that the init function is run. 34 | 35 | Now you're ready to access a database. 36 | 37 | **Previous: [Overview of Go's database/sql Package](overview.html)** 38 | **Next: [Accessing the Database](accessing.html)** 39 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Go database/sql tutorial 4 | --- 5 | 6 | The idiomatic way to use a SQL, or SQL-like, database in Go is through the 7 | [database/sql package](http://golang.org/pkg/database/sql/). It provides a 8 | lightweight interface to a row-oriented database. This website is a 9 | reference for the most common aspects of how to use it. 10 | 11 | Why is this needed? The package's documentation tells you what everything does, 12 | but it doesn't tell you how to use the package. Many of us find ourselves 13 | wishing for a quick-reference and a "getting started" orientation that tells 14 | stories instead of listing facts. Contributions are welcome; please send pull 15 | requests [here](https://github.com/VividCortex/go-database-sql-tutorial). 16 | 17 | **Start: [Overview of Go's database/sql Package](overview.html)** -------------------------------------------------------------------------------- /js/godoc.js: -------------------------------------------------------------------------------- 1 | // Except as noted, this content is licensed under Creative Commons 2 | // Attribution 3.0 3 | 4 | /* A little code to ease navigation of these documents. 5 | * 6 | * On window load we: 7 | * + Generate a table of contents (godocs_generateTOC) 8 | * + Add links up to the top of the doc from each section (godocs_addTopLinks) 9 | */ 10 | 11 | /* We want to do some stuff on page load (after the HTML is rendered). 12 | So listen for that: 13 | */ 14 | function bindEvent(el, e, fn) { 15 | if (el.addEventListener){ 16 | el.addEventListener(e, fn, false); 17 | } else if (el.attachEvent){ 18 | el.attachEvent('on'+e, fn); 19 | } 20 | } 21 | 22 | function godocs_bindSearchEvents() { 23 | var search = document.getElementById('search'); 24 | if (!search) { 25 | // no search box (index disabled) 26 | return; 27 | } 28 | function clearInactive() { 29 | if (search.className == "inactive") { 30 | search.value = ""; 31 | search.className = ""; 32 | } 33 | } 34 | function restoreInactive() { 35 | if (search.value !== "") { 36 | return; 37 | } 38 | if (search.type != "search") { 39 | search.value = search.getAttribute("placeholder"); 40 | } 41 | search.className = "inactive"; 42 | } 43 | restoreInactive(); 44 | bindEvent(search, 'focus', clearInactive); 45 | bindEvent(search, 'blur', restoreInactive); 46 | } 47 | 48 | /* Returns the "This sweet header" from

This sweet header

. 49 | * Takes a node, returns a string. 50 | */ 51 | function godocs_nodeToText(node) { 52 | var TEXT_NODE = 3; // Defined in Mozilla but not MSIE :( 53 | 54 | var text = ''; 55 | for (var j = 0; j != node.childNodes.length; j++) { 56 | var child = node.childNodes[j]; 57 | if (child.nodeType == TEXT_NODE) { 58 | if (child.nodeValue != '[Top]') { //ok, that's a hack, but it works. 59 | text = text + child.nodeValue; 60 | } 61 | } else { 62 | text = text + godocs_nodeToText(child); 63 | } 64 | } 65 | return text; 66 | } 67 | 68 | /* Generates a table of contents: looks for h2 and h3 elements and generates 69 | * links. "Decorates" the element with id=="nav" with this table of contents. 70 | */ 71 | function godocs_generateTOC() { 72 | if (document.getElementById('manual-nav')) { return; } 73 | var navbar = document.getElementById('nav'); 74 | if (!navbar) { return; } 75 | 76 | var toc_items = []; 77 | 78 | var i; 79 | var seenNav = false; 80 | for (i = 0; i < navbar.parentNode.childNodes.length; i++) { 81 | var node = navbar.parentNode.childNodes[i]; 82 | if (!seenNav) { 83 | if (node.id == 'nav') { 84 | seenNav = true; 85 | } 86 | continue; 87 | } 88 | if ((node.tagName != 'h2') && (node.tagName != 'H2') && 89 | (node.tagName != 'h3') && (node.tagName != 'H3')) { 90 | continue; 91 | } 92 | if (!node.id) { 93 | node.id = 'tmp_' + i; 94 | } 95 | var text = godocs_nodeToText(node); 96 | if (!text) { continue; } 97 | 98 | var textNode = document.createTextNode(text); 99 | 100 | var link = document.createElement('a'); 101 | link.href = '#' + node.id; 102 | link.appendChild(textNode); 103 | 104 | // Then create the item itself 105 | var item; 106 | if ((node.tagName == 'h2') || (node.tagName == 'H2')) { 107 | item = document.createElement('dt'); 108 | } else { // h3 109 | item = document.createElement('dd'); 110 | } 111 | 112 | item.appendChild(link); 113 | toc_items.push(item); 114 | } 115 | 116 | if (toc_items.length <= 1) { return; } 117 | 118 | var dl1 = document.createElement('dl'); 119 | var dl2 = document.createElement('dl'); 120 | 121 | var split_index = (toc_items.length / 2) + 1; 122 | if (split_index < 8) { 123 | split_index = toc_items.length; 124 | } 125 | 126 | for (i = 0; i < split_index; i++) { 127 | dl1.appendChild(toc_items[i]); 128 | } 129 | for (/* keep using i */; i < toc_items.length; i++) { 130 | dl2.appendChild(toc_items[i]); 131 | } 132 | 133 | var tocTable = document.createElement('table'); 134 | navbar.appendChild(tocTable); 135 | tocTable.className = 'unruled'; 136 | var tocBody = document.createElement('tbody'); 137 | tocTable.appendChild(tocBody); 138 | 139 | var tocRow = document.createElement('tr'); 140 | tocBody.appendChild(tocRow); 141 | 142 | // 1st column 143 | var tocCell = document.createElement('td'); 144 | tocCell.className = 'first'; 145 | tocRow.appendChild(tocCell); 146 | tocCell.appendChild(dl1); 147 | 148 | // 2nd column 149 | tocCell = document.createElement('td'); 150 | tocRow.appendChild(tocCell); 151 | tocCell.appendChild(dl2); 152 | } 153 | 154 | function getElementsByClassName(base, clazz) { 155 | if (base.getElementsByClassName) { 156 | return base.getElementsByClassName(clazz); 157 | } 158 | var elements = base.getElementsByTagName('*'), foundElements = []; 159 | for (var n in elements) { 160 | if (clazz == elements[n].className) { 161 | foundElements.push(elements[n]); 162 | } 163 | } 164 | return foundElements; 165 | } 166 | 167 | function godocs_bindToggle(el) { 168 | var button = getElementsByClassName(el, "toggleButton"); 169 | var callback = function() { 170 | if (el.className == "toggle") { 171 | el.className = "toggleVisible"; 172 | } else { 173 | el.className = "toggle"; 174 | } 175 | }; 176 | for (var i = 0; i < button.length; i++) { 177 | bindEvent(button[i], "click", callback); 178 | } 179 | } 180 | function godocs_bindToggles(className) { 181 | var els = getElementsByClassName(document, className); 182 | for (var i = 0; i < els.length; i++) { 183 | godocs_bindToggle(els[i]); 184 | } 185 | } 186 | function godocs_bindToggleLink(l, prefix) { 187 | bindEvent(l, "click", function() { 188 | var i = l.href.indexOf("#"+prefix); 189 | if (i < 0) { 190 | return; 191 | } 192 | var id = prefix + l.href.slice(i+1+prefix.length); 193 | var eg = document.getElementById(id); 194 | eg.className = "toggleVisible"; 195 | }); 196 | } 197 | function godocs_bindToggleLinks(className, prefix) { 198 | var links = getElementsByClassName(document, className); 199 | for (i = 0; i < links.length; i++) { 200 | godocs_bindToggleLink(links[i], prefix); 201 | } 202 | } 203 | 204 | function godocs_onload() { 205 | godocs_bindSearchEvents(); 206 | godocs_generateTOC(); 207 | godocs_bindToggles("toggle"); 208 | godocs_bindToggles("toggleVisible"); 209 | godocs_bindToggleLinks("exampleLink", "example_"); 210 | godocs_bindToggleLinks("overviewLink", ""); 211 | } 212 | 213 | bindEvent(window, 'load', godocs_onload); 214 | -------------------------------------------------------------------------------- /js/lang-go-rich.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * @fileoverview 17 | * Registers a language handler for the Go language. 18 | *

19 | * Unlike the minimal lang-go.js, this does more semantic highlighting, 20 | * similar to the highlighting in the emacs go-mode.el. 21 | *

22 | * 23 | * @author felixz@google.com 24 | */ 25 | 26 | (function () { 27 | /** @const */ var KEYWORDS = 28 | "break case chan const continue " + 29 | "default defer else fallthrough for " + 30 | "func go goto if import " + 31 | "interface map package range return " + 32 | "select struct switch type var"; 33 | 34 | /** @const */ var CONSTANTS = 35 | "true false iota nil"; 36 | 37 | /** @const */ var TYPES = 38 | "bool byte complex64 complex128 float32 float64 " + 39 | "int8 int16 int32 int64 string uint16 uint32 uint64 " + 40 | "int uint uintptr"; 41 | 42 | /** @const */ var BUILTINS = 43 | "append cap close complex copy imag len " + 44 | "make new panic print println real recover"; 45 | 46 | var shortcuts = []; 47 | var fallthrus = []; 48 | 49 | shortcuts.push( 50 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0']); 51 | 52 | // 'chars' and "strings" can't span lines 53 | shortcuts.push( 54 | [PR['PR_STRING'], /^\'(?:[^\\\'\r\n]|\\[^\r\n])*(?:\'|$)/, 55 | null, "'"]); 56 | shortcuts.push( 57 | [PR['PR_STRING'], /^\"(?:[^\\\"\r\n]|\\[^\r\n])*(?:\"|$)/, 58 | null, '"']); 59 | 60 | // `rawstrings` can span lines and do not treat \ specially 61 | shortcuts.push( 62 | [PR['PR_STRING'], /^`[^`]*(?:`|$)/, 63 | null, '`']); 64 | 65 | // numbers that start with \d 66 | shortcuts.push( 67 | [PR['PR_LITERAL'], 68 | new RegExp( 69 | '^' 70 | // A hex number 71 | + '0x[a-f0-9]+' 72 | // or an octal or decimal number, 73 | + '|\\d+(?:\\.\\d*)?' 74 | // possibly in scientific notation 75 | + '(?:e[+\\-]?\\d+)?' 76 | // possibly imaginary 77 | + 'i?', 'i'), 78 | null, '0123456789']); 79 | 80 | // numbers that start with '.' 81 | fallthrus.push( 82 | [PR['PR_LITERAL'], /^\.\d+(?:e[+\-]?\d+)?i?/i]); 83 | 84 | fallthrus.push( 85 | [PR['PR_COMMENT'], /^\/\/[^\r\n]*/]); 86 | fallthrus.push( 87 | [PR['PR_COMMENT'], /^\/\*[\s\S]*?(?:\*\/|$)/]); 88 | 89 | fallthrus.push( 90 | [PR['PR_KEYWORD'], 91 | new RegExp('^(?:' + KEYWORDS.replace(/\s+/g, '|') + ')\\b')]); 92 | 93 | fallthrus.push( 94 | [PR['PR_KEYWORD'], 95 | new RegExp('^(?:' + BUILTINS.replace(/\s+/g, '|') + ')\\b')]); 96 | 97 | fallthrus.push( 98 | [PR['PR_TYPE'], 99 | new RegExp('^(?:' + TYPES.replace(/\s+/g, '|') + ')\\b')]); 100 | 101 | fallthrus.push( 102 | [PR['PR_LITERAL'], 103 | new RegExp('^(?:' + CONSTANTS.replace(/\s+/g, '|') + ')\\b')]); 104 | 105 | fallthrus.push( 106 | [PR['PR_PUNCTUATION'], /^[+\-*\/%&|^=<>()\[\]{}!:.,;]+/]); 107 | 108 | PR['registerLangHandler']( 109 | PR['createSimpleLexer'](shortcuts, fallthrus), 110 | ['go-rich', 'go']); 111 | })(); 112 | -------------------------------------------------------------------------------- /js/prettify.js: -------------------------------------------------------------------------------- 1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= 3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), 9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, 11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, 12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), 13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} 14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ 21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), 22 | ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", 23 | /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), 24 | ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", 25 | hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= 26 | !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p 19 | stmt, err := db.Prepare("INSERT INTO users(name) VALUES(?)") 20 | if err != nil { 21 | log.Fatal(err) 22 | } 23 | res, err := stmt.Exec("Dolly") 24 | if err != nil { 25 | log.Fatal(err) 26 | } 27 | lastId, err := res.LastInsertId() 28 | if err != nil { 29 | log.Fatal(err) 30 | } 31 | rowCnt, err := res.RowsAffected() 32 | if err != nil { 33 | log.Fatal(err) 34 | } 35 | log.Printf("ID = %d, affected = %d\n", lastId, rowCnt) 36 | 37 | 38 | Executing the statement produces a `sql.Result` that gives access to statement 39 | metadata: the last inserted ID and the number of rows affected. 40 | 41 | What if you don't care about the result? What if you just want to execute a 42 | statement and check if there were any errors, but ignore the result? Wouldn't 43 | the following two statements do the same thing? 44 | 45 |

 46 | _, err := db.Exec("DELETE FROM users")  // OK
 47 | _, err := db.Query("DELETE FROM users") // BAD
 48 | 
49 | 50 | The answer is no. They do **not** do the same thing, and **you should never use 51 | `Query()` like this.** The `Query()` will return a `sql.Rows`, which reserves a 52 | database connection until the `sql.Rows` is closed. 53 | Since there might be unread data (e.g. more data rows), the connection can not 54 | be used. In the example above, the connection will *never* be released again. 55 | The garbage collector will eventually close the underlying `net.Conn` for you, 56 | but this might take a long time. Moreover the database/sql package keeps 57 | tracking the connection in its pool, hoping that you release it at some point, 58 | so that the connection can be used again. 59 | This anti-pattern is therefore a good way to run out of resources (too many 60 | connections, for example). 61 | 62 | Working with Transactions 63 | ========================= 64 | 65 | In Go, a transaction is essentially an object that reserves a connection to the 66 | datastore. It lets you do all of the operations we've seen thus far, but 67 | guarantees that they'll be executed on the same connection. 68 | 69 | You begin a transaction with a call to `db.Begin()`, and close it with a 70 | `Commit()` or `Rollback()` method on the resulting `Tx` variable. Under the 71 | covers, the `Tx` gets a connection from the pool, and reserves it for use only 72 | with that transaction. The methods on the `Tx` map one-for-one to methods you 73 | can call on the database itself, such as `Query()` and so forth. 74 | 75 | Prepared statements that are created in a transaction are bound exclusively to 76 | that transaction. See [prepared statements](prepared.html) for more. 77 | 78 | You should not mingle the use of transaction-related functions such as `Begin()` 79 | and `Commit()` with SQL statements such as `BEGIN` and `COMMIT` in your SQL 80 | code. Bad things might result: 81 | 82 | * The `Tx` objects could remain open, reserving a connection from the pool and not returning it. 83 | * The state of the database could get out of sync with the state of the Go variables representing it. 84 | * You could believe you're executing queries on a single connection, inside of a transaction, when in reality Go has created several connections for you invisibly and some statements aren't part of the transaction. 85 | 86 | While you are working inside a transaction you should be careful not to make 87 | calls to the `db` variable. Make all of your calls to the `Tx` variable that you 88 | created with `db.Begin()`. `db` is not in a transaction, only the `Tx` object is. 89 | If you make further calls to `db.Exec()` or similar, those will happen outside 90 | the scope of your transaction, on other connections. 91 | 92 | If you need to work with multiple statements that modify connection state, you 93 | need a `Tx` even if you don't want a transaction per se. For example: 94 | 95 | * Creating temporary tables, which are only visible to one connection. 96 | * Setting variables, such as MySQL's `SET @var := somevalue` syntax. 97 | * Changing connection options, such as character sets or timeouts. 98 | 99 | If you need to do any of these things, you need to bind your activity to a 100 | single connection, and the only way to do that in Go is to use a `Tx`. 101 | 102 | **Previous: [Retrieving Result Sets](retrieving.html)** 103 | **Next: [Using Prepared Statements](prepared.html)** 104 | -------------------------------------------------------------------------------- /nulls.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Working with NULLs 4 | --- 5 | 6 | Nullable columns are annoying and lead to a lot of ugly code. If you can, avoid 7 | them. If not, then you'll need to use special types from the `database/sql` 8 | package to handle them, or define your own. 9 | 10 | There are types for nullable booleans, strings, integers, and floats. Here's how 11 | you use them: 12 | 13 |
14 | for rows.Next() {
15 | 	var s sql.NullString
16 | 	err := rows.Scan(&s)
17 | 	// check err
18 | 	if s.Valid {
19 | 	   // use s.String
20 | 	} else {
21 | 	   // NULL value
22 | 	}
23 | }
24 | 
25 | 26 | Limitations of the nullable types, and reasons to avoid nullable columns in case 27 | you need more convincing: 28 | 29 | 1. There's no `sql.NullUint64` or `sql.NullYourFavoriteType`. You'd need to 30 | define your own for this. 31 | 1. Nullability can be tricky, and not future-proof. If you think something won't 32 | be null, but you're wrong, your program will crash, perhaps rarely enough 33 | that you won't catch errors before you ship them. 34 | 1. One of the nice things about Go is having a useful default zero-value for 35 | every variable. This isn't the way nullable things work. 36 | 37 | If you need to define your own types to handle NULLs, you can copy the design of 38 | `sql.NullString` to achieve that. 39 | 40 | If you can't avoid having NULL values in your database, there is another work around that most database systems support, namely `COALESCE()`. Something like the following might be something that you can use, without introducing a myriad of `sql.Null*` types. 41 |
42 | rows, err := db.Query(`
43 | 	SELECT
44 | 		name,
45 | 		COALESCE(other_field, '') as otherField
46 | 	WHERE id = ?
47 | `, 42)
48 | 
49 | for rows.Next() {
50 | 	err := rows.Scan(&name, &otherField)
51 | 	// ..
52 | 	// If `other_field` was NULL, `otherField` is now an empty string. This works with other data types as well.
53 | }
54 | 
55 | 56 | 57 | **Previous: [Handling Errors](errors.html)** 58 | **Next: [Working with Unknown Columns](varcols.html)** 59 | -------------------------------------------------------------------------------- /overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Overview 4 | --- 5 | 6 | To access databases in Go, you use a `sql.DB`. You use this type to create 7 | statements and transactions, execute queries, and fetch results. 8 | 9 | The first thing you should know is that **a `sql.DB` isn't a database 10 | connection**. It also doesn't map to any particular database software's notion 11 | of a "database" or "schema." It's an abstraction of the interface and existence 12 | of a database, which might be as varied as a local file, accessed through a network 13 | connection, or in-memory and in-process. 14 | 15 | `sql.DB` performs some important tasks for you behind the scenes: 16 | 17 | * It opens and closes connections to the actual underlying database, via the driver. 18 | * It manages a pool of connections as needed, which may be a variety of things as mentioned. 19 | 20 | The `sql.DB` abstraction is designed to keep you from worrying about how to 21 | manage concurrent access to the underlying datastore. A connection is marked 22 | in-use when you use it to perform a task, and then returned to the available 23 | pool when it's not in use anymore. One consequence of this is that **if you fail 24 | to release connections back to the pool, you can cause `sql.DB` to open a lot of 25 | connections**, potentially running out of resources (too many connections, too 26 | many open file handles, lack of available network ports, etc). We'll discuss 27 | more about this later. 28 | 29 | After creating a `sql.DB`, you can use it to query the database that it 30 | represents, as well as creating statements and transactions. 31 | 32 | **Next: [Importing a Database Driver](importing.html)** 33 | -------------------------------------------------------------------------------- /prepared.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Using Prepared Statements 4 | --- 5 | 6 | Prepared statements have all the usual benefits in Go: security, efficiency, 7 | convenience. But the way they're implemented is a little different from what 8 | you might be used to, especially with regards to how they interact with some of 9 | the internals of `database/sql`. 10 | 11 | Prepared Statements And Connections 12 | =================================== 13 | 14 | At the database level, a prepared statement is bound to a single database 15 | connection. The typical flow is that the client sends a SQL statement with 16 | placeholders to the server for preparation, the server responds with a statement 17 | ID, and then the client executes the statement by sending its ID and parameters. 18 | 19 | In Go, however, connections are not exposed directly to the user of the 20 | `database/sql` package. You don't prepare a statement on a connection. You 21 | prepare it on a `DB` or a `Tx`. And `database/sql` has some convenience 22 | behaviors such as automatic retries. For these reasons, the underlying 23 | association between prepared statements and connections, which exists at the 24 | driver level, is hidden from your code. 25 | 26 | Here's how it works: 27 | 28 | 1. When you prepare a statement, it's prepared on a connection in the pool. 29 | 2. The `Stmt` object remembers which connection was used. 30 | 3. When you execute the `Stmt`, it tries to use the connection. If it's not 31 | available because it's closed or busy doing something else, it gets another 32 | connection from the pool *and re-prepares the statement with the database on 33 | another connection.* 34 | 35 | Because statements will be re-prepared as needed when their original connection 36 | is busy, it's possible for high-concurrency usage of the database, which may 37 | keep a lot of connections busy, to create a large number of prepared statements. 38 | This can result in apparent leaks of statements, statements being prepared and 39 | re-prepared more often than you think, and even running into server-side limits 40 | on the number of statements. 41 | 42 | Avoiding Prepared Statements 43 | ============================ 44 | 45 | Go creates prepared statements for you under the covers. A simple 46 | `db.Query(sql, param1, param2)`, for example, works by preparing the sql, then 47 | executing it with the parameters and finally closing the statement. 48 | 49 | Sometimes a prepared statement is not what you want, however. There might be 50 | several reasons for this: 51 | 52 | 1. The database doesn't support prepared statements. When using the MySQL 53 | driver, for example, you can connect to MemSQL and Sphinx, because they 54 | support the MySQL wire protocol. But they don't support the "binary" protocol 55 | that includes prepared statements, so they can fail in confusing ways. 56 | 2. The statements aren't reused enough to make them worthwhile, and security 57 | issues are handled in other ways, so performance overhead is undesired. An 58 | example of this can be seen at the 59 | [VividCortex blog](https://vividcortex.com/blog/2014/11/19/analyzing-prepared-statement-performance-with-vividcortex/). 60 | 61 | If you don't want to use a prepared statement, you need to use `fmt.Sprint()` or 62 | similar to assemble the SQL, and pass this as the only argument to `db.Query()` 63 | or `db.QueryRow()`. And your driver needs to support plaintext query execution, 64 | which is added in Go 1.1 via the `Execer` and `Queryer` interfaces, 65 | [documented here](http://golang.org/pkg/database/sql/driver/#Execer). 66 | 67 | Prepared Statements in Transactions 68 | =================================== 69 | 70 | Prepared statements that are created in a `Tx` are bound exclusively to 71 | it, so the earlier cautions about repreparing do not apply. When 72 | you operate on a `Tx` object, your actions map directly to the one and only one 73 | connection underlying it. 74 | 75 | This also means that prepared statements created inside a `Tx` can't be used 76 | separately from it. Likewise, prepared statements created on a `DB` can't be 77 | used within a transaction, because they will be bound to a different connection. 78 | 79 | To use a prepared statement prepared outside the transaction in a `Tx`, you can use 80 | `Tx.Stmt()`, which will create a new transaction-specific statement from the one 81 | prepared outside the transaction. It does this by taking an existing prepared statement, 82 | setting the connection to that of the transaction and repreparing all statements every 83 | time they are executed. This behavior and its implementation are undesirable and there's 84 | even a TODO in the `database/sql` source code to improve it; we advise against using this. 85 | 86 | Caution must be exercised when working with prepared statements in 87 | transactions. Consider the following example: 88 | 89 |
 90 | tx, err := db.Begin()
 91 | if err != nil {
 92 | 	log.Fatal(err)
 93 | }
 94 | defer tx.Rollback()
 95 | stmt, err := tx.Prepare("INSERT INTO foo VALUES (?)")
 96 | if err != nil {
 97 | 	log.Fatal(err)
 98 | }
 99 | defer stmt.Close() // danger!
100 | for i := 0; i < 10; i++ {
101 | 	_, err = stmt.Exec(i)
102 | 	if err != nil {
103 | 		log.Fatal(err)
104 | 	}
105 | }
106 | err = tx.Commit()
107 | if err != nil {
108 | 	log.Fatal(err)
109 | }
110 | // stmt.Close() runs here!
111 | 
112 | 113 | 114 | Before Go 1.4 closing a `*sql.Tx` released the connection associated with it back into the 115 | pool, but the deferred call to Close on the prepared statement was executed 116 | **after** that has happened, which could lead to concurrent access to the 117 | underlying connection, rendering the connection state inconsistent. 118 | If you use Go 1.4 or older, you should make sure the statement is always closed before the transaction is 119 | committed or rolled back. [This issue](https://github.com/golang/go/issues/4459) was fixed in Go 1.4 by [CR 131650043](https://codereview.appspot.com/131650043). 120 | 121 | Parameter Placeholder Syntax 122 | ============================ 123 | 124 | The syntax for placeholder parameters in prepared statements is 125 | database-specific. For example, comparing MySQL, PostgreSQL, and Oracle: 126 | 127 | MySQL PostgreSQL Oracle 128 | ===== ========== ====== 129 | WHERE col = ? WHERE col = $1 WHERE col = :col 130 | VALUES(?, ?, ?) VALUES($1, $2, $3) VALUES(:val1, :val2, :val3) 131 | 132 | **Previous: [Modifying Data and Using Transactions](modifying.html)** 133 | **Next: [Handling Errors](errors.html)** 134 | -------------------------------------------------------------------------------- /references.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Related Reading and Resources 4 | --- 5 | 6 | Here are some external sources of information we've found to be helpful. 7 | 8 | * [http://golang.org/pkg/database/sql/](http://golang.org/pkg/database/sql/) 9 | * [http://jmoiron.net/blog/gos-database-sql/](http://jmoiron.net/blog/gos-database-sql/) 10 | * [http://jmoiron.net/blog/built-in-interfaces/](http://jmoiron.net/blog/built-in-interfaces/) 11 | * The VividCortex blog, e.g. [transparent encryption](https://vividcortex.com/blog/2014/11/11/encrypting-data-in-mysql-with-go/) 12 | * Overview of SQL Drivers from [golang github](https://github.com/golang/go/wiki/SQLDrivers) 13 | 14 | We hope you've found this website to be helpful. If you have any suggestions for 15 | improvements, please send pull requests or open an issue report at 16 | [https://github.com/VividCortex/go-database-sql-tutorial](https://github.com/VividCortex/go-database-sql-tutorial). 17 | 18 | **Previous: [Surprises, Antipatterns and Limitations](surprises.html)** 19 | -------------------------------------------------------------------------------- /retrieving.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Retrieving Result Sets 4 | --- 5 | 6 | There are several idiomatic operations to retrieve results from the datastore. 7 | 8 | 1. Execute a query that returns rows. 9 | 1. Prepare a statement for repeated use, execute it multiple times, and destroy it. 10 | 1. Execute a statement in a once-off fashion, without preparing it for repeated use. 11 | 1. Execute a query that returns a single row. There is a shortcut for this special case. 12 | 13 | Go's `database/sql` function names are significant. **If a function name 14 | includes `Query`, it is designed to ask a question of the database, and will 15 | return a set of rows**, even if it's empty. Statements that don't return rows 16 | should not use `Query` functions; they should use `Exec()`. 17 | 18 | Fetching Data from the Database 19 | =============================== 20 | 21 | Let's take a look at an example of how to query the database, working with 22 | results. We'll query the `users` table for a user whose `id` is 1, and print out 23 | the user's `id` and `name`. We will assign results to variables, a row at a 24 | time, with `rows.Scan()`. 25 | 26 |
 27 | var (
 28 | 	id int
 29 | 	name string
 30 | )
 31 | rows, err := db.Query("select id, name from users where id = ?", 1)
 32 | if err != nil {
 33 | 	log.Fatal(err)
 34 | }
 35 | defer rows.Close()
 36 | for rows.Next() {
 37 | 	err := rows.Scan(&id, &name)
 38 | 	if err != nil {
 39 | 		log.Fatal(err)
 40 | 	}
 41 | 	log.Println(id, name)
 42 | }
 43 | err = rows.Err()
 44 | if err != nil {
 45 | 	log.Fatal(err)
 46 | }
 47 | 
48 | 49 | Here's what's happening in the above code: 50 | 51 | 1. We're using `db.Query()` to send the query to the database. We check the error, as usual. 52 | 2. We defer `rows.Close()`. This is very important. 53 | 3. We iterate over the rows with `rows.Next()`. 54 | 4. We read the columns in each row into variables with `rows.Scan()`. 55 | 5. We check for errors after we're done iterating over the rows. 56 | 57 | This is pretty much the only way to do it in Go. You can't 58 | get a row as a map, for example. That's because everything is strongly typed. 59 | You need to create variables of the correct type and pass pointers to them, as 60 | shown. 61 | 62 | A couple parts of this are easy to get wrong, and can have bad consequences. 63 | 64 | * You should always check for an error at the end of the `for rows.Next()` 65 | loop. If there's an error during the loop, you need to know about it. Don't 66 | just assume that the loop iterates until you've processed all the rows. 67 | * Second, as long as there's an open result set (represented by `rows`), the 68 | underlying connection is busy and can't be used for any other query. That 69 | means it's not available in the connection pool. If you iterate over all of 70 | the rows with `rows.Next()`, eventually you'll read the last row, and 71 | `rows.Next()` will encounter an internal EOF error and call `rows.Close()` for 72 | you. But if for some reason you exit that loop -- an early return, or so on -- 73 | then the `rows` doesn't get closed, and the connection remains open. (It is 74 | auto-closed if `rows.Next()` returns false due to an error, though). This is 75 | an easy way to run out of resources. 76 | * `rows.Close()` is a harmless no-op if it's already closed, so you can call 77 | it multiple times. Notice, however, that we check the error first, and only 78 | call `rows.Close()` if there isn't an error, in order to avoid a runtime panic. 79 | * You should **always `defer rows.Close()`**, even if you also call `rows.Close()` 80 | explicitly at the end of the loop, which isn't a bad idea. 81 | * Don't `defer` within a loop. A deferred statement doesn't get executed until 82 | the function exits, so a long-running function shouldn't use it. If you do, 83 | you will slowly accumulate memory. If you are repeatedly querying and 84 | consuming result sets within a loop, you should explicitly call `rows.Close()` 85 | when you're done with each result, and not use `defer`. 86 | 87 | How Scan() Works 88 | ================ 89 | 90 | When you iterate over rows and scan them into destination variables, Go performs data 91 | type conversions work for you, behind the scenes. It is based on the type of the 92 | destination variable. Being aware of this can clean up your code and help avoid 93 | repetitive work. 94 | 95 | For example, suppose you select some rows from a table that is defined with 96 | string columns, such as `VARCHAR(45)` or similar. You happen to know, however, 97 | that the table always contains numbers. If you pass a pointer to a string, Go 98 | will copy the bytes into the string. Now you can use `strconv.ParseInt()` or 99 | similar to convert the value to a number. You'll have to check for errors in the 100 | SQL operations, as well as errors parsing the integer. This is messy and 101 | tedious. 102 | 103 | Or, you can just pass `Scan()` a pointer to an integer. Go will detect that and 104 | call `strconv.ParseInt()` for you. If there's an error in conversion, the call 105 | to `Scan()` will return it. Your code is neater and smaller now. This is the 106 | recommended way to use `database/sql`. 107 | 108 | Preparing Queries 109 | ================= 110 | 111 | You should, in general, always prepare queries to be used multiple times. The 112 | result of preparing the query is a prepared statement, which can have 113 | placeholders (a.k.a. bind values) for parameters that you'll provide when you 114 | execute the statement. This is much better than concatenating strings, for all 115 | the usual reasons (avoiding SQL injection attacks, for example). 116 | 117 | In MySQL, the parameter placeholder is `?`, and in PostgreSQL it is `$N`, where 118 | N is a number. SQLite accepts either of these. In Oracle placeholders begin with 119 | a colon and are named, like `:param1`. We'll use `?` because we're using MySQL 120 | as our example. 121 | 122 |
123 | stmt, err := db.Prepare("select id, name from users where id = ?")
124 | if err != nil {
125 | 	log.Fatal(err)
126 | }
127 | defer stmt.Close()
128 | rows, err := stmt.Query(1)
129 | if err != nil {
130 | 	log.Fatal(err)
131 | }
132 | defer rows.Close()
133 | for rows.Next() {
134 | 	// ...
135 | }
136 | if err = rows.Err(); err != nil {
137 | 	log.Fatal(err)
138 | }
139 | 
140 | 141 | Under the hood, `db.Query()` actually prepares, executes, and closes a prepared 142 | statement. That's three round-trips to the database. If you're not careful, you 143 | can triple the number of database interactions your application makes! Some 144 | drivers can avoid this in specific cases, 145 | but not all drivers do. See [prepared statements](prepared.html) for more. 146 | 147 | Single-Row Queries 148 | ================== 149 | 150 | If a query returns at most one row, you can use a shortcut around some of the 151 | lengthy boilerplate code: 152 | 153 |
154 | var name string
155 | err = db.QueryRow("select name from users where id = ?", 1).Scan(&name)
156 | if err != nil {
157 | 	log.Fatal(err)
158 | }
159 | fmt.Println(name)
160 | 
161 | 162 | Errors from the query are deferred until `Scan()` is called, and then are 163 | returned from that. You can also call `QueryRow()` on a prepared statement: 164 | 165 |
166 | stmt, err := db.Prepare("select name from users where id = ?")
167 | if err != nil {
168 | 	log.Fatal(err)
169 | }
170 | defer stmt.Close()
171 | var name string
172 | err = stmt.QueryRow(1).Scan(&name)
173 | if err != nil {
174 | 	log.Fatal(err)
175 | }
176 | fmt.Println(name)
177 | 
178 | 179 | **Previous: [Accessing the Database](accessing.html)** 180 | **Next: [Modifying Data and Using Transactions](modifying.html)** 181 | -------------------------------------------------------------------------------- /surprises.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Surprises, Antipatterns and Limitations 4 | --- 5 | 6 | Although `database/sql` is simple once you're accustomed to it, you might be 7 | surprised by the subtlety of use cases it supports. This is common to Go's core 8 | libraries. 9 | 10 | Resource Exhaustion 11 | =================== 12 | 13 | As mentioned throughout this site, if you don't use `database/sql` as intended, 14 | you can certainly cause trouble for yourself, usually by consuming some 15 | resources or preventing them from being reused effectively: 16 | 17 | * Opening and closing databases can cause exhaustion of resources. 18 | * Failing to read all rows or use `rows.Close()` reserves connections from the pool. 19 | * Using `Query()` for a statement that doesn't return rows will reserve a connection from the pool. 20 | * Failing to be aware of how [prepared statements](prepared.html) work can lead to a lot of extra database activity. 21 | 22 | Large uint64 Values 23 | =================== 24 | 25 | Here's a surprising error. You can't pass big unsigned integers as parameters to 26 | statements if their high bit is set: 27 | 28 |
 29 | _, err := db.Exec("INSERT INTO users(id) VALUES", math.MaxUint64) // Error
 30 | 
31 | 32 | This will throw an error. Be careful if you use `uint64` values, as they may 33 | start out small and work without error, but increment over time and start 34 | throwing errors. 35 | 36 | Connection State Mismatch 37 | ========================= 38 | 39 | Some things can change connection state, and that can cause problems for two 40 | reasons: 41 | 42 | 1. Some connection state, such as whether you're in a transaction, should be 43 | handled through the Go types instead. 44 | 2. You might be assuming that your queries run on a single connection when they 45 | don't. 46 | 47 | For example, setting the current database with a `USE` statement is a typical 48 | thing for many people to do. But in Go, it will affect only the connection that 49 | you run it in. Unless you are in a transaction, other statements that you think 50 | are executed on that connection may actually run on different connections gotten 51 | from the pool, so they won't see the effects of such changes. 52 | 53 | Additionally, after you've changed the connection, it'll return to the pool and 54 | potentially pollute the state for some other code. This is one of the reasons 55 | why you should never issue BEGIN or COMMIT statements as SQL commands directly, 56 | too. 57 | 58 | Database-Specific Syntax 59 | ======================== 60 | 61 | The `database/sql` API provides an abstraction of a row-oriented database, but 62 | specific databases and drivers can differ in behavior and/or syntax, such as 63 | [prepared statement placeholders](prepared.html). 64 | 65 | Multiple Result Sets 66 | ==================== 67 | 68 | The Go driver doesn't support multiple result sets from a single query in any 69 | way, and there doesn't seem to be any plan to do that, although there is [a 70 | feature request](https://github.com/golang/go/issues/5171) for 71 | supporting bulk operations such as bulk copy. 72 | 73 | This means, among other things, that a stored procedure that returns multiple 74 | result sets will not work correctly. 75 | 76 | Invoking Stored Procedures 77 | ========================== 78 | 79 | Invoking stored procedures is driver-specific, but in the MySQL driver it can't 80 | be done at present. It might seem that you'd be able to call a simple 81 | procedure that returns a single result set, by executing something like this: 82 | 83 |
 84 | err := db.QueryRow("CALL mydb.myprocedure").Scan(&result) // Error
 85 | 
86 | 87 | In fact, this won't work. You'll get the following error: _Error 88 | 1312: PROCEDURE mydb.myprocedure can't return a result set in the given 89 | context_. This is because MySQL expects the connection to be set into 90 | multi-statement mode, even for a single result, and the driver doesn't currently 91 | do that (though see [this 92 | issue](https://github.com/go-sql-driver/mysql/issues/66)). 93 | 94 | Multiple Statement Support 95 | ========================== 96 | 97 | The `database/sql` doesn't explicitly have multiple statement support, which means 98 | that the behavior of this is backend dependent: 99 | 100 |
101 | _, err := db.Exec("DELETE FROM tbl1; DELETE FROM tbl2") // Error/unpredictable result
102 | 
103 | 104 | The server is allowed to interpret this however it wants, which can include 105 | returning an error, executing only the first statement, or executing both. 106 | 107 | Similarly, there is no way to batch statements in a transaction. Each statement 108 | in a transaction must be executed serially, and the resources in the results, 109 | such as a Row or Rows, must be scanned or closed so the underlying connection is free 110 | for the next statement to use. This differs from the usual behavior when you're 111 | not working with a transaction. In that scenario, it is perfectly possible to 112 | execute a query, loop over the rows, and within the loop make a query to the 113 | database (which will happen on a new connection): 114 | 115 |
116 | rows, err := db.Query("select * from tbl1") // Uses connection 1
117 | for rows.Next() {
118 | 	err = rows.Scan(&myvariable)
119 | 	// The following line will NOT use connection 1, which is already in-use
120 | 	db.Query("select * from tbl2 where id = ?", myvariable)
121 | }
122 | 
123 | 124 | But transactions are bound to 125 | just one connection, so this isn't possible with a transaction: 126 | 127 |
128 | tx, err := db.Begin()
129 | rows, err := tx.Query("select * from tbl1") // Uses tx's connection
130 | for rows.Next() {
131 | 	err = rows.Scan(&myvariable)
132 | 	// ERROR! tx's connection is already busy!
133 | 	tx.Query("select * from tbl2 where id = ?", myvariable)
134 | }
135 | 
136 | 137 | Go doesn't stop you from trying, though. For that reason, you may wind up with a 138 | corrupted connection if you attempt to perform another statement before the 139 | first has released its resources and cleaned up after itself. This also means 140 | that each statement in a transaction results in a separate set of network 141 | round-trips to the database. 142 | 143 | **Previous: [The Connection Pool](connection-pool.html)** 144 | **Next: [Related Reading and Resources](references.html)** 145 | -------------------------------------------------------------------------------- /varcols.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: article 3 | title: Working with Unknown Columns 4 | --- 5 | 6 | The `Scan()` function requires you to pass exactly the right number of 7 | destination variables. What if you don't know what the query will return? 8 | 9 | If you don't know how many columns the query will return, you can use 10 | `Columns()` to find a list of column names. You can examine the length of this 11 | list to see how many columns there are, and you can pass a slice into `Scan()` 12 | with the correct number of values. For example, some forks of MySQL return 13 | different columns for the `SHOW PROCESSLIST` command, so you have to be prepared 14 | for that or you'll cause an error. Here's one way to do it; there are others: 15 | 16 |
17 | cols, err := rows.Columns()
18 | if err != nil {
19 | 	// handle the error
20 | } else {
21 | 	dest := []interface{}{ // Standard MySQL columns
22 | 		new(uint64), // id
23 | 		new(string), // host
24 | 		new(string), // user
25 | 		new(string), // db
26 | 		new(string), // command
27 | 		new(uint32), // time
28 | 		new(string), // state
29 | 		new(string), // info
30 | 	}
31 | 	if len(cols) == 11 {
32 | 		// Percona Server
33 | 	} else if len(cols) > 8 {
34 | 		// Handle this case
35 | 	}
36 | 	err = rows.Scan(dest...)
37 | 	// Work with the values in dest
38 | }
39 | 
40 | 41 | If you don't know the columns or their types, you should use `sql.RawBytes`. 42 | 43 |
44 | cols, err := rows.Columns() // Remember to check err afterwards
45 | vals := make([]interface{}, len(cols))
46 | for i, _ := range cols {
47 | 	vals[i] = new(sql.RawBytes)
48 | }
49 | for rows.Next() {
50 | 	err = rows.Scan(vals...)
51 | 	// Now you can check each element of vals for nil-ness,
52 | 	// and you can use type introspection and type assertions
53 | 	// to fetch the column into a typed variable.
54 | }
55 | 
56 | 57 | **Previous: [Working with NULLs](nulls.html)** 58 | **Next: [The Connection Pool](connection-pool.html)** 59 | --------------------------------------------------------------------------------