blob: 109f80247224a756fd7a6699bf9af3ec5056ac9f [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package utils
import (
"encoding/json"
)
//func info(tag string, value interface{}) {
// pc, fn, line, _ := runtime.Caller(1)
// basicFile := fn[strings.LastIndex(fn, "/")+1:]
// details := runtime.FuncForPC(pc)
// basicFnName := details.Name()[strings.LastIndex(details.Name(), ".")+1:]
// fmt.Printf("---\n[info] %s(%d): %s: %s=%+v\n", basicFile, line, basicFnName, tag, value)
//}
func FormatStructAsJsonString(a interface{}) string {
out, err := json.Marshal(a)
if err == nil {
//fmt.Println(string(out))
return string(out)
}
return ""
}