//-------------------------------------------------------------------------
326327
func get_formatter(name string) formatter {
	switch name {
	case "vim":
		return new(vim_formatter)
	case "emacs":
		return new(emacs_formatter)
	case "nice":
		return new(nice_formatter)
	case "csv":
		return new(csv_formatter)
	case "csv-with-package":
		return new(csv_with_package_formatter)
	case "json":
		return new(json_formatter)
	case "godit":
		return new(godit_formatter)
	}
	return new(nice_formatter)
}
219947
func (ListInstanceGroups) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListInstanceGroupsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListInstanceGroupsResponse was expected, got %T", resp))
		return
	}

	for i := range items.InstanceGroup {
		if !callback(&items.InstanceGroup[i], nil) {
			break
		}
	}
}
682682
func (s *LoadBalancerService) GetLoadBalancerRuleID(name string, opts ...OptionFunc) (string, int, error) {
	p := &ListLoadBalancerRulesParams{}
	p.p = make(map[string]interface{})

	p.p["name"] = name

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListLoadBalancerRules(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
	}

	if l.Count == 1 {
		return l.LoadBalancerRules[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.LoadBalancerRules {
			if v.Name == name {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
714227
func (c ColumnElem) In(args interface{}) BinaryClause {
	// Create the inner array clause and parameters
	a := ArrayClause{Clauses: make([]Clause, 0), Sep: ", "}

	// Use reflect to get arguments from the interface only if it is a slice
	s := reflect.ValueOf(args)
	switch s.Kind() {
	case reflect.Slice:
		for i := 0; i < s.Len(); i++ {
			a.Clauses = append(a.Clauses, &Parameter{s.Index(i).Interface()})
		}
	}
	// TODO What if something other than a slice is given?
	// TODO This statement should be able to take clauses / subqueries
	return BinaryClause{
		Pre:  c,
		Post: FuncClause{Inner: a},
		Sep:  " IN ",
	}
}
289600
func init() {
	buf, err := GetBytes(9)
	if err != nil {
		localID = [9]byte{'D', 'e', 'f', 'a', 'u', 'l', 't', 'I', 'D'}
	} else {
		_, err = io.ReadFull(bytes.NewBuffer(buf), localID[:])
		if err != nil {
			localID = [9]byte{'D', 'e', 'f', 'a', 'u', 'l', 't', 'I', 'D'}
		}
	}
}
737568
func (s *LoadBalancerService) GetLoadBalancerByName(name string, opts ...OptionFunc) (*LoadBalancer, int, error) {
	id, count, err := s.GetLoadBalancerID(name, opts...)
	if err != nil {
		return nil, count, err
	}

	r, count, err := s.GetLoadBalancerByID(id, opts...)
	if err != nil {
		return nil, count, err
	}
	return r, count, nil
}
1082305
func (f *File) sectionNameComp(a, b string) bool {
	if f.SectionCompFunc != nil {
		return f.SectionCompFunc(a, b)
	}

	return f.SectionNameFunc(a) == f.SectionNameFunc(b)
}
694638
func main() {
	staticFields := make(map[string]interface{})
	staticFields["foo"] = "bar"
	baseDir := ""

	if wd, err := os.Getwd(); err != nil {
		log.Fatal(err)
	} else {
		baseDir = wd
	}

	config := bunyan.Config{
		Name: "app",
		Streams: []bunyan.Stream{
			{
				Stream: os.Stdout,
			},
			{
				Path:  filepath.Join(baseDir, "info.log"),
				Level: bunyan.LogLevelInfo,
			},
			{
				Path:  filepath.Join(baseDir, "error.log"),
				Level: bunyan.LogLevelError,
			},
		},
		StaticFields: staticFields,
	}

	if l, err := bunyan.CreateLogger(config); err != nil {
		log.Fatal(err)
	} else {
		chStatic := make(map[string]interface{})
		chStatic["baz"] = "stuff"
		c := l.Child(chStatic)

		l.Info("i am the parent %d", 100)
		c.Info("i am the child")
		l.Error(errors.New("oh no!!!"), "what happened %s", "???")
	}
}
472385
func (gbi *groupByIterator) nextAtIdx(i int) {
	// loop until we find a non-empty row. This is an optimization - the loop and if/break can be removed.
	for {
		nr, rowID, wrapped := gbi.rowIters[i].Next()
		if nr == nil {
			gbi.done = true
			return
		}
		if wrapped && i != 0 {
			gbi.nextAtIdx(i - 1)
		}
		if i == 0 && gbi.filter != nil {
			gbi.rows[i].row = nr.Intersect(gbi.filter)
		} else if i == 0 || i == len(gbi.rows)-1 {
			gbi.rows[i].row = nr
		} else {
			gbi.rows[i].row = nr.Intersect(gbi.rows[i-1].row)
		}
		gbi.rows[i].id = rowID

		if !gbi.rows[i].row.IsEmpty() {
			break
		}
	}
}
755673
func (s *Statement) Id(name string) *Statement {
	t := token{
		typ:     identifierToken,
		content: name,
	}
	*s = append(*s, t)
	return s
}
948516
func init() {
	// Anything unrecognized gets redirected to the status page.
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, "/debug/status", http.StatusFound)
	})
}
422037
func (s *LoadBalancerService) GetLoadBalancerRuleByID(id string, opts ...OptionFunc) (*LoadBalancerRule, int, error) {
	p := &ListLoadBalancerRulesParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListLoadBalancerRules(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.LoadBalancerRules[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for LoadBalancerRule UUID: %s!", id)
}
863769
func main() {
	pubpipe := make(chan string)
	subpipe := make(chan string)
	go publisher(pubpipe)
	go subscriber(subpipe)
	<-subpipe
	pubpipe <- "break"
	time.Sleep(100 * time.Millisecond)
}
547737
func init() {
	gob.Register([]interface{}{})
	gob.Register(map[string]interface{}{})
	gob.Register([]map[string]string{})
	gob.Register([]map[string]int{})
	gob.Register(syscall.Signal(0x1))
}
821553
func T(defaultValue string, args ...int) string {
	if len(args) == 0 {
		return gettext.PGettext("", defaultValue)
	}
	return fmt.Sprintf(gettext.PNGettext("", defaultValue, defaultValue+".plural", args[0]),
		args[0])
}
708983
func (_m *Group) ID() string {
	ret := _m.Called()

	var r0 string
	if rf, ok := ret.Get(0).(func() string); ok {
		r0 = rf()
	} else {
		r0 = ret.Get(0).(string)
	}

	return r0
}
1344265
func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "index.html")
	})

	//When asked to log in, generate a unique state and store the entered values in a cookie to retreive on callback
	http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
		r.ParseForm()
		s := &sessionInformation{
			ClientID:        r.FormValue("client_id"),
			Secret:          r.FormValue("secret"),
			RequestedScopes: r.FormValue("requested_scopes"),
		}
		fmt.Printf("Logging in to %s with secret %s and asking for scopes %s\n", s.ClientID, s.Secret, s.RequestedScopes)

		randombytes := make([]byte, 12) //Multiple of 3 to make sure no padding is added
		rand.Read(randombytes)
		state := base64.URLEncoding.EncodeToString(randombytes)

		serializedSessionInformation, _ := json.Marshal(s)
		sessionCookie := &http.Cookie{
			Name:   state,
			Value:  base64.URLEncoding.EncodeToString(serializedSessionInformation),
			MaxAge: 5 * 60, // 5 minutes
		}
		http.SetCookie(w, sessionCookie)

		u, _ := url.Parse("https://dev.itsyou.online:8443/v1/oauth/authorize")
		q := u.Query()
		q.Add("client_id", s.ClientID)
		q.Add("redirect_uri", "http://localhost:8080/callback")
		q.Add("scope", s.RequestedScopes)
		q.Add("state", state)
		q.Add("response_type", "code")
		u.RawQuery = q.Encode()
		http.Redirect(w, r, u.String(), http.StatusFound)
	})

	http.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
		r.ParseForm()
		code := r.FormValue("code")
		fmt.Println("Code: ", code)
		state := r.FormValue("state")

		sessionCookie, err := r.Cookie(state)
		if err != nil || sessionCookie == nil {
			fmt.Println("Failed to retrieve session cookie: ", err)
			fmt.Println("Cookie: ", sessionCookie)
			return
		}

		fmt.Println("Cookie value: ", sessionCookie.Value)

		decodedCookie, err := base64.URLEncoding.DecodeString(sessionCookie.Value)
		if err != nil {
			fmt.Println("Could not decode session cookie value: ", err)
		}
		s := &sessionInformation{}

		err = json.Unmarshal(decodedCookie, s)
		if err != nil {
			fmt.Println("Failed to convert session cookie: ", err)
			return
		}

		fmt.Println(s)

		tr := &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		}
		hc := &http.Client{Transport: tr}
		req, err := http.NewRequest("POST", "https://dev.itsyou.online:8443/v1/oauth/access_token", nil)
		if err != nil {
			return
		}
		q := req.URL.Query()
		q.Add("client_id", s.ClientID)
		q.Add("client_secret", s.Secret)
		q.Add("code", code)
		q.Add("redirect_uri", "http://localhost:8080/callback")
		q.Add("state", state)
		req.URL.RawQuery = q.Encode()

		resp, err := hc.Do(req)
		if err != nil {
			fmt.Println("Error while getting the access token: ", err)
			return
		}
		defer resp.Body.Close()

		body, err := ioutil.ReadAll(resp.Body)

		fmt.Println("Response body: ", string(body))
		return

	})

	log.Fatal(http.ListenAndServe(":8080", nil))

}