Twelve Go Best Practices
Francesc Campoy Flores Gopher at Google @francesc http://campoy.cat/+
- Best practices
| #!/usr/bin/env python | |
| """A simple python script template. | |
| """ | |
| from __future__ import print_function | |
| import os | |
| import sys | |
| import argparse |
Twelve Go Best Practices
Francesc Campoy Flores Gopher at Google @francesc http://campoy.cat/+
| fields @timestamp | |
| | parse "MDW|*|*|*|*|*|*|*\"" as @servlet, @method, @url, @code, @startime, @endtime, @elapsed | |
| | filter level == "INFO" | |
| | filter message like "MDW|" | |
| | sort @elapsed desc | |
| | limit 20 |
| ######################### APM Server Configuration ######################### | |
| ################################ APM Server ################################ | |
| apm-server: | |
| # Defines the host and port the server is listening on. Use "unix:/path/to.sock" to listen on a unix domain socket. | |
| host: "0.0.0.0:8200" | |
| # Maximum permitted size in bytes of a request's header accepted by the server to be processed. | |
| #max_header_size: 1048576 |
| # Kibana is served by a back end server. This setting specifies the port to use. | |
| #server.port: 5601 | |
| # Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values. | |
| # The default is 'localhost', which usually means remote machines will not be able to connect. | |
| # To allow connections from remote users, set this parameter to a non-loopback address. | |
| server.host: "0.0.0.0" | |
| # Enables you to specify a path to mount Kibana at if you are running behind a proxy. | |
| # Use the `server.rewriteBasePath` setting to tell Kibana if it should remove the basePath |
| #!/bin/bash | |
| docker network create elastic | |
| docker run -d --network elastic -p 9200:9200 -p 9300:9300 --name elasticsearch --restart=always -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.4.0 | |
| docker run -d --network elastic --name apm-server --restart=always -p 8200:8200 --user root -v /home/ec2-user/apm-server.docker.yml:/usr/share/apm-server/apm-server.yml:ro -e output.elasticsearch.hosts=["elasticsearch:9200"] docker.elastic.co/apm/apm-server:7.4.0 | |
| docker run -d -p 5601:5601 --name kibana --network elastic --restart=always -v /home/ec2-user/kibana.yml:/usr/share/kibana/config/kibana.yml kibana:7.4.0 |
| #!/usr/bin/python | |
| """ | |
| Usage: | |
| python swagger-yaml-to-html.py < /path/to/api.yaml > doc.html | |
| """ | |
| import yaml, json, sys | |
| TEMPLATE = """ |
| USERNAME [a-zA-Z0-9._-]+ | |
| USER %{USERNAME} | |
| EMAILLOCALPART [a-zA-Z][a-zA-Z0-9_.+-=:]+ | |
| EMAILADDRESS %{EMAILLOCALPART}@%{HOSTNAME} | |
| INT (?:[+-]?(?:[0-9]+)) | |
| BASE10NUM (?<![0-9.+-])(?>[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+))) | |
| NUMBER (?:%{BASE10NUM}) | |
| BASE16NUM (?<![0-9A-Fa-f])(?:[+-]?(?:0x)?(?:[0-9A-Fa-f]+)) | |
| BASE16FLOAT \b(?<![0-9A-Fa-f.])(?:[+-]?(?:0x)?(?:(?:[0-9A-Fa-f]+(?:\.[0-9A-Fa-f]*)?)|(?:\.[0-9A-Fa-f]+)))\b |
| def signature = 'method groovy.json.JsonBuilder call java.util.List' | |
| org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.get().approveSignature(signature) |